Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

def Calculator():

option = input("""

--------Calculator--------

| 1. Addition |

| 2. Subtraction |

| 3. Multiplication |

| 4. Division |

| Choose Any Option(1-4) |

--------------------------

""")

if option == "1":

n1 = float(input("Enter no.1: "))

n2 = float(input("Enter no.2: "))

print(f'Sum = {n1 + n2}')

elif option == "2":

n1 = float(input("Enter no.1: "))

n2 = float(input("Enter no.2: "))

print(f'Difference = {n1 - n2}')

elif option == "3":

n1 = float(input("Enter no.1: "))

n2 = float(input("Enter no.2: "))

print(f'Product = {n1 * n2}')

elif option == "4":

n1 = float(input("Enter no.1: "))

n2 = float(input("Enter no.2: "))

print(f'Quotient = {n1 / n2}')

else:
print("Invalid Input")

def Palindrome():

no = input("Enter a no.: ")

a = no[::-1]

if no == a:

print(f'{no} is a Palindrome')

else:

print(f'{no} is not a Palindrome')

def Prime():

n = int(input("enter a number"))

for i in range(2, n, 1):

if n % i == 0:

print("Not Prime")

break

else:

continue

else:

print("Prime")

def Armstrong():

n1 = n2 = n = int(input("Enter a no."))

c = len(str(n1))

arm = 0

while n > 0:

d = n % 10
n = n // 10

arm = arm + d ** c

if arm == n2:

print(f"{n2} is an Armstrong no.")

else:

print(f"{n2} is not an Armstrong no.")

def Pattern():

n = int(input('Enter no. of rows: '))

for i in range(1, n + 1):

print('*' * i)

def main_menu():

print("""

-----------Menu-----------

| 1. Open Calculator |

| 2. Palindrome Check |

| 3. Prime No. Check |

| 4. Armstrong No. Check |

| 5. '*' Pattern |

| Choose Any Option(1-5) |

--------------------------

""")

pick = input()

if pick == "1":

Calculator()
elif pick == "2":

Palindrome()

elif pick == "3":

Prime()

elif pick == "4":

Armstrong()

elif pick == "5":

Pattern()

else:

print("Wrong Input")

Continue = "y"

while Continue == "y":

main_menu()

Continue = input("would you like to continue?(y/n)")

else:

print("Thank you for using this Program")

You might also like