phython
phython
#addition
#subtraction
#multiplication
#division
# Addition
# Subtraction
# Multiplication
# Division
print("Select Operations")
print(
"1. Addition\n"
"2. Subtraction\n"
"3. Multiplication\n"
"4. Division\n")
if operation == 1:
print (n1, "+", n2, "=", addition(n1, n2))
elif operation == 2:
print (n1, "-", n2, "=", subtraction(n1, n2))
elif operation == 3:
print (n1, "*", n2, "=", multiplication(n1, n2))
elif operation == 4:
print (n1, "/", n2, "=", division(n1, n2))
else:
print("Invalid Input")
Copy code
Output
Explanation:
The above Program is created in three steps:
Step -1: Define Functions: Addition, Subtraction, Multiplication, and Division
Step-2: Promoting Input from the user
(i). Choosing which operation to perform
(ii). Enter the first and second numbers (float data type)
Step-3: Apply Conditional Statements: To make operation as-per-user
choices
Must Read: def keyword in Python
Must Read: Data Type in Python
Output
Enter length of the rectangle: 23
Enter breadth of the rectangle: 17
Area of rectangle = 391.0
Perimeter of rectangle = 782.0
In this program you will learn about how to do Mathematical functions using
Python.
This program will helpful to calculate square and cube of a number
And then by using the given formula you will get output.
Here is the code