# A python program that uses 'Conditional statements / Decision Making' and operates on user specified input
num1=input("enter first number:"); # This will read the input and tries to understand.
num2=int(raw_input("enter second number:")); #raw_input() will convert the provided input to string by default. Ex: try removing typecasting int() and run and provide the operation 1 or 6 and see the difference.
print("*****Possible Arithmetic operations*****\n");
print("1. Addition");
print("2. Subtraction");
print("3. Multiplication");
print("4. Division");
print("5. Modulo");
print("6. Exponent");
operation=input("******Enter the Arithmetic operation you would like to perform******* \n");
if operation==1:
addRes=num1+num2;
print("Addition of {0} and {1} is {2} \n".format(num1,num2,addRes));
elif operation==2:
subRes=num1-num2;
print("Subtraction of {0} and {1} is {2} \n".format(num1,num2,subRes));
elif operation==3:
mulRes=num1*num2;
print("Multiplication of {0} and {1} is {2}\n".format(num1,num2,mulRes));
elif operation==4:
divRes=float(num1)/float(num2);
print("Division of {0} and {1} is {2}\n".format(num1,num2,divRes));
elif operation==5:
modRes=float(num1)/float(num2);
print("Modulous of {0} and {1} is {2}\n".format(num1,num2,modRes));
elif operation==6:
expRes=num1**num2;
print("Exponent of {0} and {1} is {2}\n".format(num1,num2,expRes));
else:
print("No such option available");
Labels: Python Programming
0 Comments:
Subscribe to:
Post Comments (Atom)