menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Register
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
Write a program that loops one thousand times. add all the even numbers and display the results. add all the odd numbers and display the results.
asked
May 23, 2018
197k
views
2
votes
Write a program that loops one thousand times. add all the even numbers and display the results. add all the odd numbers and display the results.
Computers and Technology
high-school
Milan Surelia
asked
by
Milan Surelia
6.5k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
5
votes
# Python v3
odd = 0
even = 0
for i in range( 1000 ): # Note: zero indexed!
if( i % 2 ):
even += i
else:
odd += i
print( "The even numbers add up to %d" % even )
print( "The odd numbers add up to %d" % odd )
MaddEye
answered
May 29, 2018
by
MaddEye
6.7k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
7.2m
questions
9.6m
answers
Other Questions
Seven basic internal components found in a computer tower
describe an advance in technology that makes life more enjoyable. what discoveries contribute to this technology?
Disadvantages of using animation in advertising? advantages and disadvantages of using animation for education? advantages and disadvantages of using animation in entertainment?
This is science they just dont have the subject buy anyways describe interactions you have with the environment that you depend on to meet your basic needs hope u can help
If a person sends email from a school computer or a business computer, should that message be considered private? Does the institution or person that owns the computer from which email is sent have a right
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org