I am having problems with finger exercise 2.2.Can anyone please tell me where I went wrong? Thanks a Lot ##x = int(raw_input('Enter an Integer:')) ##y = int(raw_input('Enter an Integer:')) ##z = int(raw_input('Enter an Integer:')) ##if x > y and x > z: ## if x%3 == 0: ## print 'x is largest odd number' ##if y > z: ## if y%3 == 0: ## print 'y is largest odd number' ##if z%3 == 0: ## print 'z is largest odd number' ##else ## print 'there are no odd numbers'
I don't know the specifications of this problem, but I don't understand why you check `z % 3 == 0` each time. Please explain the nature of the problem; I doubt anyone here knows the course well enough to have memorized each question.
Odd/even checking is usually done with ( ( x % 2 ) == 0 ) . 3 doesn't make sense to me. Something like this, you may want to consider if elif else instead of many if statements. IMO, liberal use of parenthesis in comparisons make the logic much more apparent.
to specify further, there are two cases to hand when doing x mod 2 x mod 2 == 1 -> odd x mod 2 == 0 ->even
Join our real-time social learning platform and learn together with your friends!