Beginners Code"s for Python
#display the maximum value in set of 3 numbers
x, y, z = input("Enter three value: ").split()
print("First Number is: ", x)
print("Second Number is: ", y)
print("Third Number is: ", z)
print()
if x>y and x>z:
print("max value is :",x)
elif y>z:
print("max value is :",y)
else:
print("max value is :",z)
_ _ _ _ _ _ _ _ __ _ _ __ _ _ __ __ __ _ _ __ __ _ __ _ _ _ _ _ __ _ _ _ _ _ _ _ __ _
#display first ten natural numbers
x=1
print(x)
while x<10:
x=x+1
print(x)
-------------------------------------------------------------------------------------
## FAULTY CALCULATOR CODE##printing the welcome lines
print("Welcome to faulty calculator")
print("What you want to do?")
print("For Addition select +")
print("For Subtraction select -")
print("For Multiplication select *")
print("For Division select /")
num1=int(input("Enter the first number :-"))#taking inputs
num2=int(input("Enter the Second number :-"))
i=input("Enter your choice of operation:-")
if num1==56 and num2==9 and i=="+" :#critical code
print("77")
elif num1==56 and num2==6 and i=="/":
print("4")
elif num1==45 and num2==3 and i=="*":
print("555")
elif i=="+":
print("The result is ",num1+num2)
elif i=="-":
print("The Result is ",num1-num2)
elif i=="/":
print("The Result is ",num1/num2)
elif i=="*":
print("The Result is ",num1*num2)
print("DO YOU WANT TO CONTINUE CALCULATING?")
print("For Yes press Y and For No press N")
z=input("Enter :-")
if z=="Y" or z=="y":
num1 = int(input("Enter the first number :-"))
num2 = int(input("Enter the Second number :-"))
i = input("Enter your choice of operation:-")
if num1 == 56 and num2 == 9 and i == "+":
print("77")
elif num1 == 56 and num2 == 6 and i == "/":
print("4")
elif num1 == 45 and num2 == 3 and i == "*":
print("555")
elif i == "+":
print("The result is ", num1 + num2)
elif i == "-":
print("The Result is ", num1 - num2)
elif i == "/":
print("The Result is ", num1 / num2)
elif i == "*":
print("The Result is ", num1 * num2)
print("DO YOU WANT TO CONTINUE CALCULATING?")
print("For Yes press Y and For No press N")
z = input("Enter :-")
Comments
Post a Comment