Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make a calculator

import time
times = 3

for x in range (times):
  def calculate(a, b, formula):
    if formula == '+':
      return a + b
    elif formula == '-':
      return a - b
    elif formula == '*':
      return a * b
    elif formula == '/':
      return a / b
    else:
      print('Just Leave!')
      return 'Closing program...'

  print('Choose a number')
  a = float(input())
  print('Choose a second number')
  b = float(input())
  print('Do you want to * / - or + ?')
  formula = input()
  answer = calculate(a, b, formula)
  print(answer)
sleep(3)
Comment

PREVIOUS NEXT
Code Example
Python :: activate venv in python 
Python :: python string: immutable string 
Python :: a int and float python 
Python :: dataframe cut 
Python :: python pattern 
Python :: casefold in python 
Python :: javascript or python 
Python :: api key python 
Python :: mro in python 
Python :: python print variable name 
Python :: opencv rgb to gray custom 
Python :: install multiple versions of python 
Python :: Python NumPy asfarray Function Example List to float type array 
Python :: receipt parsing 
Python :: timeit command line 
Python :: sklearn euclidean distance 
Python :: django.db.utils.IntegrityError: NOT NULL constraint failed 
Python :: Use the correct syntax to print the first item in the fruits tuple. 
Python :: tkinter bind function with arguments 
Python :: python calculator app 
Python :: pyplot histogram labels in center 
Python :: how to add percentages to ylabel python 
Python :: python returning rows and columns from a matrix string 
Python :: deduplication jaccard python 
Python :: how to use list compression with conditional formatting 
Shell :: install git on amazon linux 
Shell :: check nginx status 
Shell :: docker remove none images 
Shell :: git save password global 
Shell :: knockback stick command 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =