Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

funny application in python

""" Calculator
----------------------------------------
"""
def addition ():
    print("Addition")
    n = float(input("Enter the number: "))
    t = 0 //Total number enter
    ans = 0
    while n != 0:
        ans = ans + n
        t+=1
        n = float(input("Enter another number (0 to calculate): "))
    return [ans,t]
def subtraction ():
    print("Subtraction");
    n = float(input("Enter the number: "))
    t = 0 //Total number enter
    sum = 0
    while n != 0:
        ans = ans - n
        t+=1
        n = float(input("Enter another number (0 to calculate): "))
    return [ans,t]
def multiplication ():
    print("Multiplication")
    n = float(input("Enter the number: "))
    t = 0 //Total number enter
    ans = 1
    while n != 0:
        ans = ans * n
        t+=1
        n = float(input("Enter another number (0 to calculate): "))
    return [ans,t]
def average():
    an = []
    an = addition()
    t = an[1]
    a = an[0]
    ans = a / t
    return [ans,t]
// main...
while True:
    list = []
    print(" My first python program!")
    print(" Simple Calculator in python by Malik Umer Farooq")
    print(" Enter 'a' for addition")
    print(" Enter 's' for substraction")
    print(" Enter 'm' for multiplication")
    print(" Enter 'v' for average")
    print(" Enter 'q' for quit")
    c = input(" ")
    if c != 'q':
        if c == 'a':
            list = addition()
            print("Ans = ", list[0], " total inputs ",list[1])
        elif c == 's':
            list = subtraction()
            print("Ans = ", list[0], " total inputs ",list[1])
        elif c == 'm':
            list = multiplication()
            print("Ans = ", list[0], " total inputs ",list[1])
        elif c == 'v':
            list = average()
            print("Ans = ", list[0], " total inputs ",list[1])
        else:
            print ("Sorry, invilid character")
    else:
        break
Comment

PREVIOUS NEXT
Code Example
Python :: Get the positions of items of ser2 in ser1 as a list python 
Python :: Dynamically limiting queryset of related field 
Python :: Python downsampling 
Python :: coin flip numpy 
Python :: Python - Comment convertir la corde à la date 
Python :: Python - Cara Memisahkan String Berdasarkan Beberapa Delimiter 
Python :: grep alternative in python 
Python :: Regression model build 
Python :: membuat chat bot dengan python 
Python :: form is undefined flask 
Python :: credential not provided when i try to sign up a new user django 
Python :: is complex datatype immutable in python 
Python :: pygame.k_kp_enter 
Python :: sonido sfr200a 
Python :: pandas : stratification (mean) 
Python :: semaphore example in python 
Python :: django rest framework not getting form 
Python :: background subtraction params opencv python 
Python :: pandas converters example 
Python :: Fernet: Cannot decrypt strings saved in csv with pandas 
Python :: how to print the text new line instead of n in jupyter notebook 
Python :: comprehensions 
Python :: text to qr code python 
Python :: django form is onvalid 
Python :: transpose 3d matrix pytorch 
Python :: python move all txt files 
Python :: round up 
Python :: matruzen rechner python 
Python :: how to remove zero after decimal float python 
Python :: .close() python 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =