+ 2
Not understanding what is being asked?
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 Sample Input: 1 Sample Output: 3 Hint: An integer is even if it is divisible by two and odd if it is not even. Does anyone know how this problem should be split into solvable steps? Thank you
10 Antworten
+ 7
Hello!
I solved by telling him it's an integer. You have to put int before number. Like this:
number = input()
#your code goes here
if int(number)%2==0:
print(int(number)*2)
elif not int(number)%2==0:
print(int(number)*3)
elif int(number)==0:
print(number)
0
Thats what I wrote:
number = int(input())
#your code goes here
if number // 2:
print(number + number)
elif not number // 2:
print(number + number + number)
elif num == 0:
print(num)
But the 4th is still failing. Can someone please help me. Thank you!
0
number = input()
#your code goes here
if int(number) % 2 == 0:
print(int(number) * 2)
elif int(number) != 0:
print(int(number) * 3)
elif int(number)==0:
print(number)
0
Here is another option:
number = int(input())
if number % 2 == 0:
print(number * 2)
elif number % 2 == 1:
print(number * 3)
0
if number % 2 == 0:
print(number * 2)
elif number % 2 != 0:
print(number * 3)
elif number == 0:
print(number)
0
number = int(input())
#your code goes here
if (number % 2 == 0):
print (number * 2)
elif (number % 1 == 0):
print (number *3)
elif (number == 0):
print ("0")
0
number = input()
if int(number) % 2 == 0:
print(int(number) * 2)
elif int(number) % 2 != 0:
print(int(number) * 3)
elif int(number) == 0:
print(int(number))
0
number = int(input())
if number % 2 == 0:
print(number*2)
elif number % 1 == 0:
print(number*3)
else:
print(0)