Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

make calculator in python

option = int(input("Enter Your Choice 1(Add)/2(Sub)/3(Divide)/4(Multiply): "))

# Check if the option is a valid operation
if option > 4:
    print("enter a valid Number")
    exit()
    
# Get the 2 numbers which will be calculating on
num1 = int(input("Enter Number 1: "))
num2 = int(input("Enter Number 2: "))

if option == 1:
    print("The Sum Is ", num1 + num2)
elif option == 2:
    print("The Difference Is ", num1 - num2)
elif option == 3:
    print("The Division Is ", num1 / num2)
elif option == 4:
    print("The Product Is ", num1 * num2)
elif option == 5:
    print("The Power Is ", num1 ** num2)
Comment

how to make a calcukatir un python

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 :: python create empty list 
Python :: change version of python that poetry use 
Python :: df.info() in python 
Python :: python loop 3 times 
Python :: Convert .tif images files to .jpeg in python 
Python :: email validation using django 
Python :: NEW CALENDAR MODULE 
Python :: series change index pandas 
Python :: python dataframe find no of true 
Python :: numpy find index of matching values 
Python :: python print binary tree 
Python :: pythagore 
Python :: Python NumPy column_stack Function Syntax 
Python :: receipt ocr 
Python :: text to png python 
Python :: editing specific line in text file in python 
Python :: how to remove text in pygame 
Python :: bytes to Image PIL PY 
Python :: python global keyword 
Python :: shebang line python 
Python :: read text file python path open 
Python :: elif "wikipedia" 
Python :: draw a bow tie in python 
Python :: without @tf.function OOM 
Python :: python event start from file funcion 
Shell :: remove phpmyadmin from ubuntu 
Shell :: conda install gensim 
Shell :: check react version 
Shell :: conda install keras 
Shell :: git undo soft reset 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =