Advertisement
probiner

Untitled

Oct 11th, 2012
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. # Finger Exercise: The largest odd integer of 10 integers inputs
  2.  
  3. #
  4. # Each input value is checked for being both odd and bigger than the previous stored input value, and if so, it's value is stored replacing the previous.
  5. #
  6.  
  7. count=0     # No. of inputs variable
  8. uicomp=0        # Previous input value store variable
  9. while count<10:
  10.     ui=int(raw_input('Enter ten integer numbers | ' + str(10-count) + ' remain'))       #input countdown display
  11.     if ui%2!=0 and ui>uicomp: # the current input is checked if he is both odd and larger than the previous.
  12.         uicomp=ui   # Store variable rebind
  13.     count+=1    # Iteration incremental
  14. if uicomp==0:   # when no inputs are odd
  15.     print 'No odd integer was inputted.'
  16. else:   #The last standing odd is printed
  17.     print 'The largest odd integer that was inputted is ' +str(uicomp)+'.'
  18.  
  19. #
  20. # End of program.
  21. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement