(python )calculator using match case in python switch the particular value between different cases :

 #calculator using match case

# it switch the particular value between different cases :

# index:
print("1= Addition")
print("2= Subtractin")
print("3= multiplication")
print("4= division")

# user choice:
choice=int(input("Enter your choice:"))

# match case
match choice:
    case 1:
        print("Enter two number:")
        a,b=int(input()),int(input())
        c=a+b
        print("sum is:",c)
       
    case 2:
        print("Enter two number:")
        a,b=int(input()),int(input())
        c=a-b
        print("subtraction is:",c)
       
       
    case 3:
        print("Enter two number:")
        a,b=int(input()),int(input())
        c=a*b
        print("multipication is:",c)          
       
    case 4:
        print("Enter two number:")
        a,b=int(input()),int(input())
        c=a/b
        print("division is:",c)

Comments

Popular posts from this blog

Write a python script to display the current date and time. First create variables to store date and time, then display date and time in proper format (like: 13-8-2022 and 9:00 PM """