{"id":9135,"date":"2021-09-30T11:30:07","date_gmt":"2021-09-30T06:00:07","guid":{"rendered":"https:\/\/python-programs.com\/?p=9135"},"modified":"2021-11-22T18:35:30","modified_gmt":"2021-11-22T13:05:30","slug":"python-program-to-read-two-numbers-and-print-their-quotient-and-remainder","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-read-two-numbers-and-print-their-quotient-and-remainder\/","title":{"rendered":"Python Program to Read Two Numbers and Print Their Quotient and Remainder"},"content":{"rendered":"
Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example<\/a> guide and practice well.<\/p>\n Given two numbers , the task is to print their quotient and Remainder in\u00a0 Python.<\/p>\n Examples:<\/strong><\/p>\n i)Floating Division<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n ii)Integer Division<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to print the quotient and Remainder:<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Related Programs<\/strong>:<\/p>\n Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example guide and practice well. Given two numbers , the task is to print their quotient and Remainder in\u00a0 Python. Examples: i)Floating Division Example1: Input: first number =45 second number =17 Output: The value of quotient after dividing …<\/p>\nfirst number =45\r\nsecond number =17<\/pre>\n
The value of quotient after dividing 45 \/ 17 = 2.6470588235294117\r\nThe value of remainder after dividing 45 \/ 17 = 11<\/pre>\n
first number =45\r\nsecond number =17<\/pre>\n
The value of quotient after dividing 45 \/ 17 = 2\r\nThe value of remainder after dividing 45 \/ 17 = 11<\/pre>\n
Program to Read Two Numbers and Print Their Quotient and Remainder in\u00a0 Python<\/h2>\n
\n
1)Using \/ and % modulus operator in Python (User Input separated by new line, Float Division)<\/h3>\n
\n
# scanning the given two numbers using int(input()) function\r\n# first number\r\nnumb1 = int(input(\"Enter some random number = \"))\r\n# second number\r\nnumb2 = int(input(\"Enter some random number = \"))\r\n# Calculate the quotient by using the syntax first number \/second number\r\n# and store it in a variable.\r\nquotie = numb1\/numb2\r\n# Calculate the remainder by using the syntax first number %second number\r\n# and store it in a variable.\r\nremain = numb1 % numb2\r\n# Print the above two variables which are the result of the program\r\nprint(\"The value of quotient after dividing\", numb1, \"\/\", numb2, \" = \", quotie)\r\nprint(\"The value of remainder after dividing\",\r\n numb1, \"\/\", numb2, \" = \", remain)\r\n<\/pre>\n
Enter some random number = 86\r\nEnter some random number = 12\r\nThe value of quotient after dividing 86 \/ 12 = 7.166666666666667\r\nThe value of remainder after dividing 86 \/ 12 = 2<\/pre>\n
2)Using \/ and % modulus operator in Python (User Input separated by spaces , Float Division)<\/h3>\n
\n
# Scan the given two numbers using map and split() functions\r\n# to store them in two separate variables.\r\nnumb1, numb2 = map(int, input(\"Enter two random numbers separated by spaces = \").split())\r\n# Calculate the quotient by using the syntax first number \/second number\r\n# and store it in a variable.\r\nquotie = numb1\/numb2\r\n# Calculate the remainder by using the syntax first number %second number\r\n# and store it in a variable.\r\nremain = numb1 % numb2\r\n# Print the above two variables which are the result of the program\r\nprint(\"The value of quotient after dividing\", numb1, \"\/\", numb2, \" = \", quotie)\r\nprint(\"The value of remainder after dividing\",\r\n numb1, \"\/\", numb2, \" = \", remain)\r\n<\/pre>\n
Enter two random numbers separated by spaces = 45 17\r\nThe value of quotient after dividing 45 \/ 17 = 2.6470588235294117\r\nThe value of remainder after dividing 45 \/ 17 = 11<\/pre>\n
3)Using \/\/ and % modulus operator in Python (User Input separated by spaces , Integer Division)<\/h3>\n
\n
# Scan the given two numbers using map and split() functions\r\n# to store them in two separate variables.\r\nnumb1, numb2 = map(int, input(\"Enter two random numbers separated by spaces = \").split())\r\n# Calculate the quotient by using the syntax first number \/second number\r\n# and store it in a variable.\r\nquotie = numb1\/\/numb2\r\n# Calculate the remainder by using the syntax first number %second number\r\n# and store it in a variable.\r\nremain = numb1 % numb2\r\n# Print the above two variables which are the result of the program\r\nprint(\"The value of quotient after dividing\", numb1, \"\/\", numb2, \" = \", quotie)\r\nprint(\"The value of remainder after dividing\",\r\n numb1, \"\/\", numb2, \" = \", remain)\r\n<\/pre>\n
Enter two random numbers separated by spaces = 45 17\r\nThe value of quotient after dividing 45 \/ 17 = 2\r\nThe value of remainder after dividing 45 \/ 17 = 11<\/pre>\n
\n