Basic Programming in Python

 





'''#1.Display hello world
print("Hello world")'''


'''#2. Data types
i=(5)
f=(6.13665665454545)
c="a"
print(i,f,c)'''


'''#3.Basic calculator
a=float(input("Enter the value of a="))
b=float(input("Enter the value of b="))
add=print("Addition=",a+b)
sub=print("Subtraction=",a-b)
mul=print("Multiplication=",a*b)
div=print("Division=",a/b)'''

'''#4. Volume of cube
a=int(input("Enter the value="))
volume=print("Volume of cube=",a*a*a)'''

'''#5.Swaping the number using the third variable
a=6
b=7
c=0
print("Before Swapping a=",a,"b=",b)
c=a
a=b
b=c
print("After Swapping a=",a,"b=",b)'''

''''#6. Check no. is odd or even
a=int(input("Enter the value="))
if(a%2==0):
    print(a,"is an Even number")

else:
    print(a,"is an Odd Number")'''


"""#7. check negative and positive number

a=int(input("Enter the value="))
if(a>=0):
    print(a,"is an Positive number")

else:
    print(a,"is an Negative Number")"""

'''#8. Exam result analysis system
a=float(input("Enter Your marks="))
if(a>=26 and a<=30):
    print("You are passed with A grade")
elif(a>=21 and a<=25):
    print("You are passed with B grade")
elif(a>=13 and a<=20):
    print("You are passed with C grade")
elif(a==12):
    print("You are passed with D grade")
else:
    print("Alert! you are failed")'''

'''#9. Find the largest number among the three
a=int(input("Enter a="))
b=int(input("Enter b="))
c=int(input("Enter c="))
if a>b and a>c:
    print(a," is greater")
elif b>a and b>c:
    print(b,"is greater")
elif c>a and c>b:
    print(c,"is greater")
else:
    print("Same numbers")'''

#10.basic calculator using switch
a=float(input("Enter value of a="))
b=float(input("Enter the value of b="))
op=input("Select the operator=")
match op:
    case '+':
        print("Add of a and b=",a+b)
    case '-':
        print("Sub of a and b=",a-b)
    case '*':
        print("Mul of a and b=",a*b)
    case '/':
        print("Div of a and b=",a/b)
    case _:
        print("Invalid operator")

Comments