0

Hello! Who helps me with exersice 20.5, please?

This is my code: number = input() if number == "1": print (int(number)*3) elif number == "2": print (int(number)*2) elif number == "0": print (int(number)*0) elif number == "2;4;6;...;": print (int(number)*2) else: print (int(number)*3)

16th Jan 2022, 3:05 AM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar
2 odpowiedzi
+ 3
G'day Jefferson Jesus Beleño Suarez Are you trying to code for: Write a program that takes a number as input and - returns its double, if the number is even - returns its triple, if the number is odd - returns 0, if number is 0 Have you seen the modulo % mathematical operation? Modulo gives the remainder from a division, eg: 5%2==1 16%2==0 Could you use that to select even numbers (hint, make your code check if 👉number==0👈 before doing an 👉elif number%2==0👈) Happy Python coding!
16th Jan 2022, 3:33 AM
HungryTradie
HungryTradie - avatar
0
It only returns me 0. number = input() if number == number: print (int(number)%3) elif number == number: print (int(number)%2) elif number == number: print (int(number)%0) HungryTradie
16th Jan 2022, 11:59 AM
Jefferson Jesus Beleño Suarez
Jefferson Jesus Beleño Suarez - avatar