Question 8)
Write a program in Python to divide two numbers.
Write a program in Python to divide numbers 10 by 2.
Write a program to divide two numbers by taking user input using Python Programming.
Program to find the divide two integer values in Python.
Program to find the divide two float values in Python.
Code Example 1: Divide two Integers
# Program 9: Example 1
# Divide two hardcoded int values 2 and 5
# 1000+ Python Programs by Code2care.org
int_no_1 = 10
int_no_2 = 2
divide_value = int_no_1 / int_no_2
print(f"Division of {int_no_1} and {int_no_2} is {divide_value}")
Output:
Division of 10 and 2 is 5

Code Example 2: Divide two integer numbers from user input
# Program 9: Example 2
# Divide two ints from the user input
# 1000+ Python Programs by Code2care.org
int_no_1 = int(input("Enter int 1: "))
int_no_2 = int(input("Enter int 2: "))
divide_value = int_no_1 / int_no_2
print(f"Division of {int_no_1} by {int_no_2} is {divide_value}")
Output:
Enter int 1: 20
Enter int 2: 2
Division of 20 by 2 is 10
Code Example 3: Divide two floats numbers from user input
# floats 8: Example 3
# Divide two ints from the user input
# 1000+ Python Programs by Code2care.org
float_no_1 = float(input("Enter int 1: "))
float_no_2 = float(input("Enter int 2: "))
divide_value = float_no_1 / float_no_2
print(f"Division of {int_no_1} by {int_no_2} is {divide_value}")
Output:
Enter int 1: 10.4
Enter int 2: 2.4
Division of 10.4 and 2.4 is 24.96
Explaination:
List of functions used,
- print(): Built-in function to print a string on the console with f-strings formatting.
- float(): Built-in function to convert String argument to float value.
- input(): Built-in function to accept user input
Steps:
- Create a variable to hold the first integer/float
- Create a variable to hold a second integer/float
- Create a third variable to hold the division of two variables using the / (slash) division operator.
- Print the result using print() function.
-
Have Questions? Post them here!
More Posts related to Python-Programs,
- Program 9: Divide Two Numbers - 1000+ Python Programs
- Program 10: Modulo of Two Numbers - 1000+ Python Programs
- Program 1: Print Hello World! - 1000+ Python Programs
- Program 6: Find Sum of Two Floating Numbers - 1000+ Python Programs
- Program 3: Print the name of user as input - 1000+ Python Programs
- Program 8: Multiply Two Numbers - 1000+ Python Programs
- Program 5: Find Sum of Two Integer Numbers - 1000+ Python Programs
- Program 7: Find Difference of Two Numbers - 1000+ Python Programs
- Program 4: Input Name and Age and Print - 1000+ Python Programs
- Program 2: Print your name using print() function - 1000+ Python Programs
More Posts:
- Microsoft Lists and SharePoint Online edit grid view - use undo and redo changes - SharePoint
- Update SharePoint Online List Item using REST API, HTML, Spfx, Postman - SharePoint
- How to enable Auto-Save Files in VS Code - HowTos
- How to Manage Profile Picture on Microsoft Teams - Teams
- What Java version is used for Minecraft 1.18 - Java
- [Updated] macOS 13 Ventura Supported Mac Devices List - MacOS
- How to reset AirPods or AirPods Pro using iPhone/iPad or iPod - iOS
- How to enable, create and use Virtual Breakout Rooms in Microsoft Teams - Teams