Write a simple calculator with +, -, *, / support in python | write a simple calculator with python. Python simple calculator.

Write a simple calculator with +, -, *, / support in python

 Solution:


   
    print("Welcome to python simple Calculator")

    a = float(int(input("enter a number: ")))
    b= float(int(input("enter second number: ")))
    o = float(input("press 1 to add, 2 to substract, 3 to multiply, 4 to divide: "))

    if o == 1:
        print("Addition is:", a+b)
    if o == 2:
        print("substract is:", a-b)
    if o == 3:
        print("multiply is:", a*b)
    if o == 4:
        print("divide is:", a/b)



 

 

 another one with %

Write a simple calculator with +, -, *, /,%  support in python.

 Solution:

   
    print("Welcome to python simple Calculator")
 
 number_1 = float(int(input("Enter 1st number: ")))
    number_2 = float(int(input("Enter 2nd number: ")))

    fun = int(input("1 to add, 2 to subtract, 3 to multiply, 4 to division, 5 to mod: "))

    if fun == 1:
        print("your addition is", number_1 + number_2)
    elif fun == 2:
        print("Subtraction is", number_1  - number_2)
    elif fun == 3:
        print("multiply is", number_1 * number_2)
    elif fun == 4:
        print("Division is", number_1 / number_2)
    elif fun == 5:
        print("mod is", number_1 % number_2)
    else:
        print("Invalid Key")



 

إرسال تعليق (0)
أحدث أقدم