probiner

EdFitzgerald's Largest Odd of three Variables

Oct 11th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. # Program to solve finger problem.
  2. #
  3. # Put some sample values in x, y, and z.
  4. #
  5. x = 4
  6. y = 16
  7. z = 24
  8. #
  9. # Initialize biggest to zero. If it never gets updated, this flags the case
  10. # where no variable is an odd number.
  11. #
  12. biggest = 0
  13. if x % 2:   #check x odd
  14.     biggest = x
  15. if (y % 2) & (y > biggest): #check y odd and bigger than x
  16.         biggest = y
  17. if (z % 2) & (z > biggest): #check z odd and bigger than x or y
  18.         biggest = z
  19. #
  20. # Now print biggest odd integer or no odd integer.
  21. #
  22. if biggest: #check biggest > 0
  23.     print "Biggest odd integer is " + str(biggest)
  24. else:
  25.     print "No odd integer found."
  26. #
  27. # End of program.
  28. #
Advertisement
Add Comment
Please, Sign In to add comment