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.
Hint: If you use division (/) to calculate the quotient, you will need to use int() to remove the decimals. You can also use integer division (// ), which was introduced in Question 10 of Lesson Practice 2.3.
Once you've calculated the quotient, you will need to use modular division (%) to calculate the remainder. Remember to clearly define the data types for all inputs in your code. You may need to use float( ) , int( ), and str( ) in your solution.
.
num = int(input("Enter Numerator "))
den = int(input("Enter Denominator "))
print("quotient is ",str(num//den)," remainder is ", str(num%den))
Sample input :
Enter Numerator10
Enter Denominator3
quotient is 3 remainder is 1
Comments
Leave a comment