{{#items}}

{{text}}

{{/items}} {{ctaText}}

{{#items}} {{/items}}

showing results for - "advanced calculator in python"

Emna

01 Aug 2020

```
1def add(n1, n2):
2 return n1 + n2
3
4def subtract(n1, n2):
5 return n1 - n2
6
7def multiply(n1, n2):
8 return n1 * n2
9
10def divide(n1, n2):
11 return n1 / n2
12
13operations = {
14 "+": add,
15 "-": subtract,
16 "*": multiply,
17 "/": divide
18}
19
20def calculator():
21 try:
22 num1 = float(input("Enter first number?: "))
23 for symbol in operations:
24 print(symbol)
25 operation_symbol = input("Pick an operation: ")
26 if operation_symbol not in operations:
27 return "Opration choosen is not valid"
28 num2 = float(input("Enter second number?: "))
29 calculation_function = operations[operation_symbol]
30 answer = calculation_function(num1, num2)
31 except:
32 return "An error happened because of your input try again"
33 return(f"{num1} {operation_symbol} {num2} = {answer}")
34
35while True:
36 print(calculator())
37 to_continue = input("Type 'y' to do more calculations, or type 'n' to exit the app:- ").lower()
38 if to_continue == 'y':
39 continue
40 elif to_continue == "n":
41 print("Exiting The App")
42 break
43
```

similar questions

how to make a calculator in pythonhowt to make caluclator in pythoncalculator with pythonhow to build a better calculator in pythonhow to create calculator in pythoncreate calculator in pythonpython mayusculashow to make a calculator in python using object oriented programminghow to make a game score calculator in pythonadvanced python coursehow to make a calculator using pythonhow to make a python calculatorcalculator python tutorialadvanced bmi calculator using pythoncalculator in pythoncalculator in pythonpython calculatorpython calculatorcalculator pythonbasic calculator in pythonhow to create a calculator in pythonsimple python calculatorfree fall calculator pythonsimple calculator in pythonsimple interest calculator using pythonqueries leading to this page

the most advanced calculator in python source codehow to make advanced calculator in python advancedcalculator codes in pythonhow to create advance calculator with pythonpython advanced calculatoradvanced calculator codes in pythonadvanced calculator pythonpython advance calculatoradvanced calculator in pythonadvanced calculator in python your answer for

you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content

please ensure to add code which is syntactically corrent and executes properly

ask question on maxinterview

you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content

please be clear, to the point and respectful