File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change 1
- # Write a program that prompts the user for two numbers and then computes them using the following rules.
2
- # If the first number is greater than the second one, the second number is subtracted from the first one.
3
- # If the second number is greater than the first one, the first number is divided by the second one.
4
- # Otherwise, the two numbers are added.
5
- num1 = int (input ("Enter first number: " ))
6
- num2 = int (input ("Enter second number: " ))
1
+ # Write a program to read a value from the keyboard and output the phrase NEGATIVE if the number is negative,
2
+ # POSITIVE if the number is positive or ZERO otherwise.
3
+ value = int (input ("Enter a value from the keyboard: " ))
7
4
8
- if num1 > num2 :
9
- print ("num1 - num2 = " + str ( num1 - num2 ) )
10
- elif num1 < num2 :
11
- print ("num2 // num1 = " + str ( num1 / num2 ) )
5
+ if value < 0 :
6
+ print ("NEGATIVE" )
7
+ elif value > 0 :
8
+ print ("POSITIVE" )
12
9
else :
13
- print ("Num1 + num2 = " + str ( num1 + num2 ) )
10
+ print ("ZERO" )
14
11
15
12
You can’t perform that action at this time.
0 commit comments