Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
RCMorea
Group Title
I've just started this course and I have the book.
I did the finger exercise after section 2.2 and am quite pleased that it works.
The finger exercise after section 2.4 seems to be solvable by the same method, but it becomes tedious to enter and compare 10 variables. I wanted to do it with only 2 variables and a loop. I was able to, but only by setting the initial value of one variable to an arbitrary low negative value. This seems a bit of a cheat. Is there a more elegant way to do this?

print 'Given ten integers, this program will tell the highest odd.'
count = 0
y = 999999999999
for count in range (0, 10):
x = int(raw_input('Enter an integer.'))
if x>=y and (abs(x)%2)==1:
y = x
count = count + 1
if y ==999999999999:
print 'All of the inputs are even.'
else:
print y, 'is the greatest odd.'
 one year ago
 one year ago
RCMorea Group Title
I've just started this course and I have the book. I did the finger exercise after section 2.2 and am quite pleased that it works. The finger exercise after section 2.4 seems to be solvable by the same method, but it becomes tedious to enter and compare 10 variables. I wanted to do it with only 2 variables and a loop. I was able to, but only by setting the initial value of one variable to an arbitrary low negative value. This seems a bit of a cheat. Is there a more elegant way to do this?  print 'Given ten integers, this program will tell the highest odd.' count = 0 y = 999999999999 for count in range (0, 10): x = int(raw_input('Enter an integer.')) if x>=y and (abs(x)%2)==1: y = x count = count + 1 if y ==999999999999: print 'All of the inputs are even.' else: print y, 'is the greatest odd.'
 one year ago
 one year ago

This Question is Closed
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.