#if elif
"""
if<conditional statement>:
<stat1>
<stat2>
elif <conditional statement>:
<stat>
<stat>
elif <conditional statement>:
<stat>
<stat>
else:
<stat>
<stat>
<stat22>
"""
print("Comparing two numbers ")
n1=int(input("Enter First Number "))
n2=int(input("Enter Second Number "))
if n1>n2:
print("First Number is greter ")
elif n2>n1:
print("Second is greater ")
else:
print("Both are equal")
#P1. To input alphabet (a-d) and print
# apple for a
# ball for b
# cat for c
# dog for d
# dont know for others
ch=input("ENter Alphabet in lower case")
if ch=='a':
print("apple")
elif ch=='b':
print("ball")
elif ch=='c':
print("cat")
elif ch=='d':
print("dog")
else:
print("dont know")
#P2.To input a number (1-7) and print corresponding day of week
#1- Monday, 2- Tuesday.......
day=int(input("Enter Number 1-7")
if day==1:
print("Monday")
elif day==2:
print("Tuesday")
elif day==3:
print("Wednesday")
elif day==4:
print("Thursday")
elif day==5:
print("Friday")
elif day==6:
print("Saturday")
elif day==7:
print("Sunday")
else:
print("Wrong Input")
print("END")
#P3. WAP to input 2 integers and an arithmatic operator(+,-,*,/,//,**,%)
# and print result
a=int(input("Enter First Number "))
b=int(input("Enter Second Number "))
op=input("Enter Operator ")
result=0
if op=='+':
result=a+b
elif op=='-':
result=a-b
elif op=='*':
result=a*b
elif op=='/':
result=a/b
elif op=='//':
result=a//b
elif op=='%':
result=a%b
elif op=='**':
result=a**b
else:
print("Please Enter Valid Operator")
print("Reuslt=",result)
#P4. Write a Program to input a Positive Integer and print
#it is in Ones, Tens, Hundreds or thousands
num=int(input("Enter Number "))
if num>=0 and num<=9:
print("Ones")
elif num>=10 and num<=99:
print("Tens")
elif num>=100 and num<=999:
print("Hundreds")
elif num>=1000 and num<=9999:
print("THousands")
else:
print("Wrong Input ")
#P4. Input Marks of 5 subjects and print Division on percentage:
#percentage Division
#>=60 First
#45-60 Second
#33-45 Third
#<33 Fail
sub1 = int(input("Marks of English:"))
sub2 = int(input("Marks of Computer:"))
sub3 = int(input("Marks of Accountancy:"))
sub4 = int(input("Marks of Business Studies:"))
sub5 = int(input("Marks of Economics:"))
sum = sub1+sub2+sub3+sub4+sub5
per = (sum/500)*100
print("Total Marks Obtained = :",sum,"/500")
print("Total Percentage = :",per)
if per>=60:
print("First Division")
elif per>=45 and per<60:
print("Second Division")
elif per>=33 and per<45:
print("Third Division")
else:
print("Fail")
#P5. WAP to input 3 integers and print greatest of them
n1=int(input("ENter First Number "))
n2=int(input("ENter Second Number "))
n3=int(input("ENter Third Number "))
if n1>n2 and n1>n3:
print("First is greatest")
elif n2>n1 and n2>n3:
print("Second is greatest")
elif n3>n1 and n3>n2:
print("Third is greatest")
elif n1==n2 and n2==n3:
print("All are equal")
#P6. Input radius of circle and a number(1 for area, 2 for cirumference
# 3 for perimeter)
r=float(input("Enter radius of Circle"))
num=int(input("Enter 1 for Area of the Circle\n2 for Diameter of the circle n3 for Circumference of
the circle "))
if num==1:
print("Area= ", 3.14*r*r)
elif num==2:
print("Diameter= ",2*r)
elif num==3:
print("Circumference= ",2*3.14*r)
else:
print("Wrong Choice")
#P7. A company buys steel and grades it on certain parameters:
# (i)Hardness must be greater than 50.
# (ii)Carbon content must be less than 0.7.
# (iii)Tensile strength must be greater than 5600.
#The grades are as follows:
#Grade is 10 if all three conditions are met.
#Grade is 9 if conditions (i) and (ii) are met.
#Grade is 8 if conditions (ii) and (iii) are met.
#Grade is 7 if conditions (i) and (iii) are met.
#Grade is 6 if only one condition is met.
#Grade is 5 if none of three conditions are met.
#Write a program, if the user gives values of hardness, carbon content
#and tensile strength of the steel under consideration and display the
#grade of the steel.
Hardness = int(input("Enter Hardness Value "))
Carbon = float(input("Enter Carbon Value "))
Tensile = int(input("Enter Tensile Value "))
if Hardness > 50 and Carbon < 0.7 and Tensile > 5600:
print ('Grade 10')
elif Hardness > 50 and Carbon < 0.7:
print ('Grade 9')
elif Carbon < 0.7 and Tensile > 5600:
print ('Grade 8')
elif Hardness > 50 and Tensile > 5600:
print ('Grade 7')
elif Hardness > 50 or Carbon < 0.7 or Tensile > 5600:
print ('Grade 6')
elif Hardness < 50 and Carbon > 0.7 and Tensile < 5600:
print ('Grade 5')
#P8. WAP To Print following menu
#1. Area of circle
#2. Area of Square
#3. Area Of Rectangle
#Enter your choice(1-3)
#Now on Users Choice particular program should execute
print("1. Area of circle")
print("2. Area of Square")
print("3. Area Of Rectangle")
ch=int(input("Enter your choice(1-3) "))
if ch==1:
r=float(input("Enter radius of Circle "))
print("Area= ", 3.14*r*r)
elif ch==2:
s=float(input("Enter length of side of the square "))
print("Area of the square with sides",s," is = ",s*s)
elif ch==3:
w=float(input("Enter Width of Rectangle "))
h=float(input("Enter Height of Rectangle "))
print("Area of the Rectangle is = ",w*h)
else:
print("Incorrect Choice ")