146k views
0 votes
How to write a program that prompts the user to input two POSITIVE numbers — a dividend (numerator) and a divisor (denominator). Your program should then divide the numerator by the denominator, and display the quotient followed by the remainder in python.

User Chanlito
by
3.8k points

1 Answer

5 votes

Answer:

num1 = int(input("Numerator: "))

num2 = int(input("Denominator: "))

if num1 < 1 or num2<1:

print("Input must be greater than 1")

else:

print("Quotient: "+str(num1//num2))

print("Remainder: "+str(num1%num2))

Step-by-step explanation

The next two lines prompts the user for two numbers

num1 = int(input("Numerator: "))

num2 = int(input("Denominator: "))

The following if statement checks if one or both of the inputs is not positive

if num1 < 1 or num2<1:

print("Input must be greater than 1")-> If yes, the print statement is executed

If otherwise, the quotient and remainder is printed

else:

print("Quotient: "+str(num1//num2))

print("Remainder: "+str(num1%num2))

User Jundl
by
3.8k points