WWW Programiz
WWW Programiz
Courses Tut orials Examples Search tutorials & examples Try Programiz PRO
Python Examples
Python Basic Input and Output # This function divides two numbers
def divide(x, y):
Python input()
return x / y
Python map() Function
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
while True:
# take input from the user
choice = input("Enter choice(1/2/3/4): ")
Run Code
Output
Select operation.
1.Add
2.Subtract
3.Multiply
4.Divide
Your
Enter privacy choices
choice(1/2/3/4): 3
Enter first number: 15
We and 816 TCF partners and other partners process personal data such as
Enter second number: 14
cookies, unique identifiers, and other device data. Some partners may process your
15.0 * 14.0 = 210.0
personal data on the basis of legitimate interest. View a list of partners to see the
Let's do next calculation? (yes/no): no
purposes they believe they have legitimate interest or and how you can object to it.
We and 816 TCF partners and other partners may use your data for the listed
purposes, you can manage
In thisyour choices bywe
program, askManage
clicking Options.
the user You can an operation.
to choose Options 1, 2,
change your settings at any time, including by withdrawing your consent, by clicking
the cog icon at corner3,
or and 4 at
are valid. If any
page.other input is given,
the link bottom of the
Invalid Input is displayed
and the loop continues until a valid option is selected.
Purposes
Two numbers are taken and an if...elif...else branching is used to
Store and/or access information on a device
execute a particular section. User-defined functions add() ,
subtract()
Develop and improve services , multiply() and divide() evaluate respective operations
and display the output.
Personalised advertising and content, advertising and content measurement, and
audience research
Special Features
Manage Options
Python if else Agree and proceed
Related Examples
Find the Largest Add Two Numbers Find LCM Python User-defined
Among Three Functions
Numbers
Go Tut orial
C# Tut orial
Apps
Learn Java Courses Tut orials Examples Search tutorials & examples Try Programiz PRO
Purposes
Special Features
Powered by UniConsent