Calculator’s Code
print("Login")
name = input("Enter your Name: ")
print("Welcome to the worlds's most advanced
Calculator",name)
n1 = input("Enter the 1st number: ")
n2 = input("Enter the 2nd number: ")
try:
n1 = float(n1)
n2 = float(n2)
except:
print("Please enter numbers")
exit()
print("Select the operation you want to perform \n
hello")
print("Select from the given options below:")
print("+")
print("-")
print("*")
print("/")
op = input("Which operation do you want to perform -
")
if op == "+":
sum = n1+n2 #Not allowed
print(f"The sum of n1 and n2 is: {sum}")
if op == "-":
sub = n1-n2
print(f"The difference of n1 and n2 is: {sub}")
if op == "*":
mul = n1*n2
print(f"{n1} times {n2} is: {mul}")
if op == "/" and n2 != 0:
print(f"{n1} divided by {n2} is {d}")
elif op == "/" and n2 == 0:
print("You can't divide a number by zero \n Btw,
thanks for using me!")
exit()
print("Thank you for using the world's most advanced
calculator",name)
print("Have a nice Day :)")
ATM’S CODE
print("Welcome to your digital ATM")
ab = 100
for i in range(3):
pin = input("Enter the 4 digit PIN: ")
if pin == "1234":
print("Logged in successfully")
break
else:
print("Invalid pin ", 2-i," attempts left")
else:
print("We are very sorry to inform you that your ATM is blocked
forever!")
exit()
print(f"Available balance is: {ab}")
while True:
menu = input("Enter the serial number of the action you want to
perform \n" "[Link] \n" "[Link] \n" "[Link] Balance \n" "[Link]
\n" "Enter here: ")
if menu in ("1","2"):
a = input("Enter the amount: $")
try:
a = float(a)
except:
print("Please enter a valid amount!")
break
if a > ab and menu == "1":
print("Insufficient Balance!!")
elif menu == "1":
ab = ab-a
print(f"Available balance: ${ab}")
if menu == "2":
ab = ab+a
print(f"Available Balance: ${ab}")
elif menu == "3":
print(f"Available Balance is: ${ab}")
elif menu == "4":
print("Have a nice day buddy :) ")
break
else:
print("Invalid command mate!!")
STOCK MANAGER’S CODE
stock = {}
print("Welcome to your Stock Manager")
while True:
print("[Link]/Update Stock")
print("[Link] Stock")
print("[Link] Stock")
print("[Link]")
try:
menu = int(input("Enter the serial no of function you want to perform - "))
except:
print("Please enter the options given above only!!")
# ADD
if menu == 1:
add = input("Enter the Name of Product - ").lower()
if add == "":
print("Product Name can't be empty")
continue
try:
qnt = float(input("Enter the Quantity of Product - "))
except:
print("Please enter the quanity in numbers!!")
continue
if add in stock:
stock[add] += qnt
else:
stock[add] = qnt
print("Current Stock of ",add," is ",stock[add])
#Sell
if menu == 2:
sub = input("Enter the Name of Product: ").lower()
if sub not in stock:
print("Item not Found!!")
continue
try:
qnt = float(input("Enter the Quantity of Product - "))
except:
print("Please enter the quanity in numbers")
continue
if sub in stock and qnt <= stock[sub]:
stock[sub] -= qnt
print("The Remaining Stock of ",sub," is ",stock[sub])
else:
print("Insufficient Stock")
print("Actual Stock of ",sub," is ",stock[sub])
#Examine
if menu == 3:
if stock == {}:
print("Your Warehouse is EMPTY!!")
else:
print("NAME \t\t QUANTITY")
for item in stock:
print(item, "\t\t", stock[item])
#EXIT
if menu == 4:
print("Exiting Stock Manager. Have a Great Day! :)")
break