Q. Consider the following program code:
dividend_str = input ("Enter an integer to divide: ") divisor_str = input ("Enter an integer to divide it by: ") dividend_int = int(dividend_str) divisor_int = int(divisor_str) if divisor_int == 0: print ("Divisor is:", divisor_int) print ("Can't divide by 0") print ("Run the program again and enter a non-zero divisor") if divisor_int != 0: print ("The result of", dividend_str, "/", \ divisor_str, "is:", dividend_int/divisor_int) print ("Thank You")
Figure out the output when you enter inputs (in the same order as shown here) as:
S. No. | Inputs | Output produced |
---|---|---|
(a) | 45, 2 | |
(b) | 45, 0 | |
(c) | 45, 1 | |
(d) | 45, -1 |
Answer :-
S. No. | Inputs | Output produced |
---|---|---|
(a) | 45, 2 | Enter an integer to divide: 45 Enter an integer to divide it by: 2 The result of 45 / 2 is: 22.5 Thank You >>> |
(b) | 45, 0 | Enter an integer to divide: 45 Enter an integer to divide it by: 0 Divisor is: 0 Can't divide by 0 Run the program again and enter a non-zero divisor Thank You >>> |
(c) | 45, 1 | Enter an integer to divide: 45 Enter an integer to divide it by: 1 The result of 45 / 1 is: 45.0 Thank You >>> |
(d) | 45, -1 | Enter an integer to divide: 45 Enter an integer to divide it by: -1 The result of 45 / -1 is: -45.0 Thank You >>> |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )