Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)
If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call (countdown or countup) for input of zero.
Provide the following.
This is code:
print('Enter a number: ')
num = int(input())
if num >= 0:
num -= 1
else:
num += 1
print(num)
Output:
2
1
0
-1
-5
-4
Explanation about zero: Because I think, that zero is more positive, than negative.
Comments
Leave a comment