{"id":20406,"date":"2021-09-11T15:38:10","date_gmt":"2021-09-11T10:08:10","guid":{"rendered":"https:\/\/python-programs.com\/?p=20406"},"modified":"2021-11-22T18:36:21","modified_gmt":"2021-11-22T13:06:21","slug":"python-program-for-division-two-numbers-operator-without-using-division-operator","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-division-two-numbers-operator-without-using-division-operator\/","title":{"rendered":"Python Program For Division Two Numbers Operator Without Using Division(\/) Operator"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Subtract Two Numbers Without Using Minus(-) Operator<\/a><\/p>\n Given two numbers and the task is to find the division of given two numbers without using Division(\/)\u00a0 Operator in python.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to find the division of given two numbers without using the division(\/) operator in python:<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Note<\/strong>: If you want to get the result in float format give float<\/strong> in place if int.<\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n If you are new to the Python Programming Language then practice using our Python Programming Examples for Beginners<\/a> as our expert team has designed them from scratch.<\/p>\n In the previous article, we have discussed Python Program to Subtract Two Numbers Without Using Minus(-) Operator Given two numbers and the task is to find the division of given two numbers without using Division(\/)\u00a0 Operator in python. Examples: Example1: Input: Given First Number = 400 Given Second Number = 200 Output: The Division of …<\/p>\nGiven First Number = 400\r\nGiven Second Number = 200<\/pre>\n
The Division of above given two numbers{ 400 \/ 200 } =2<\/pre>\n
Given First Number = 75\r\nGiven Second Number = 15<\/pre>\n
The Division of above given two numbers{ 75 \/ 15 } =5<\/pre>\n
Program For Division Two Numbers Operator Without Using Division(\/) Operator in Python<\/h2>\n
\n
Method #1: Using While Loop (Static Input)<\/h3>\n
\n
# Give the first number as static input and store it in a variable.\r\nfst_numb = 400\r\n# Give the second number as static input and store it in another variable.\r\nscnd_numb = 200\r\n# Take a variable say rslt_divsn and initialize its value to 0.\r\nrslt_divsn = 0\r\nprint(\"The Division of above given two numbers{\",\r\n fst_numb, \"\/\", scnd_numb, \"} =\", end=\"\")\r\n# Loop until the given first number is greater than or equal to the given second\r\n# number using the while loop.\r\nwhile fst_numb >= scnd_numb:\r\n # Inside the loop, subtract the second number from the given first number and store\r\n # the result in the first number.\r\n fst_numb = fst_numb-scnd_numb\r\n # Increment the value of the above-initialized variable rslt_divsn by 1 and store it in\r\n # the same variable.\r\n rslt_divsn += 1\r\n# Print rslt_divsn to get the division of given two numbers without using the division(\/)\r\n# operator.\r\nprint(rslt_divsn)\r\n<\/pre>\n
The Division of above given two numbers{ 400 \/ 200 } =2<\/pre>\n
Method #2: Using While loop (User Input)<\/h3>\n
\n
# Give the first number as user input using the int(input()) function and\r\n# store it in a variable.\r\nfst_numb = int(input(\"Enter some random number = \"))\r\n# Give the second number as user input using the int(input()) function and\r\n# store it in another variable.\r\nscnd_numb = int(input(\"Enter some random number = \"))\r\n# Take a variable say rslt_divsn and initialize its value to 0.\r\nrslt_divsn = 0\r\nprint(\"The Division of above given two numbers{\",\r\n fst_numb, \"\/\", scnd_numb, \"} =\", end=\"\")\r\n# Loop until the given first number is greater than or equal to the given second\r\n# number using the while loop.\r\nwhile fst_numb >= scnd_numb:\r\n # Inside the loop, subtract the second number from the given first number and store\r\n # the result in the first number.\r\n fst_numb = fst_numb-scnd_numb\r\n # Increment the value of the above-initialized variable rslt_divsn by 1 and store it in\r\n # the same variable.\r\n rslt_divsn += 1\r\n# Print rslt_divsn to get the division of given two numbers without using the division(\/)\r\n# operator.\r\nprint(rslt_divsn)\r\n<\/pre>\n
Enter some random number = 450\r\nEnter some random number = 15\r\nThe Division of above given two numbers{ 450 \/ 15 } =30<\/pre>\n
\n