Python- IF based- applications only


Good Morning Students

Today we will look at the solution of very simple python programs using the Conditional construct-If statement

The Google meet link for this session is:

Meeting ID

----------------------------------------------------------------------------------------------------------
By the end of the session you will be able to

  • apply the concept of a simple IF construct to understand the If and the ELSE components
  • apply the concept of a simple IF construct to understand the If ,elif and the ELSE components
  • understand the nested IF construct.
----------------------------------------------------------------------------------------------------------

EXERCISE

1). Write a program in Python to accept the class of a student (in numbers). If the class entered is 10 or 12, display"Board Class" else display "Non-Board Class".

#PROGRAM TO CHECK THE CLASS OF THE STUDENT
cls=int(input("Enter the class of the student-"))
if(cls==10 or cls==12):
    print("The student is in Board Class")
else:

    print("The student is not in Board Class")





2) Write a program in Python to accept a number from the user check and print whether it is evenodd or zero.
(NOTE- even numbers on division by 2 give zero as remainder
               odd numbers on division by  2 give non-zero remainder)

#PROGRAM TO CHECK WHETHER THE NUMBER IS ODD,EVEN OR ZERO 
num=int(input("Enter the number-"))
if(num==0):
    print("The number is Zero")
elif(num%2==0):
    print(num," is an Even Number")
else:

    print(num," is an Odd Number")
Q3. 
 #PROGRAM TO ACCEPT THE NUMERIC VALUE OF CLASS AND DISPLAY IN WORDS 
num=int(input("Enter your class-"))
if(num==4):
    print("You are a student of Class FOUR")
elif(num==5):
    print("You are a student of Class FIVE")
elif(num==6):
    print("You are a student of Class SIX")
elif(num==7):
     print("You are a student of Class SEVEN")
elif(num==8):
    print("You are a student of Class EIGHT")
elif(num==9):
    print("You are a student of Class NINE")                  
elif(num==10):
    print("You are a student of Class TEN")
else:
    print(num," is NOT A MEMBER OF Middle Section")






Comments

Post a Comment

Popular posts from this blog

HOLIDAY HW