IF - REVIEW(exercises given)
Good Morning Boys
Let us look at the IF based questions given in the EXERCISE WORK. We will do so one by one.
------------------------------------------------------------------------------------------------------------------------
Link for the Google Meet class is as follows:
We will try ALL the programs discussed on the Python IDLE environment.
-----------------------------------------------------------------------------------------------------------------------
By the end of this session, you will be able to:
1. WAP to accept the age of the user and check whether he/she can vote or not.
PYTHON PROGRAM:
#PROGRAM TO CHECK WHETHER THE USER CAN VOTE OR NOT
age=int(input("Enter your age: "))
if (age<18):
print("You can not vote")
else:
print("You can vote")
----------------------------------------------------------------------------------------------------------
2. Write a program to accept a number from the user and find whether its is positive, negative or zero using the decision statements.
PYTHON PROGRAM:
#PROGRAM TO CHECK WHETHER THE ENTERED NUMBER IS POSITIVE , NEGATIVE OR ZERO
num=int(input("Enter the number: "))
if (num==0):
print("The entered number is ZERO")
elif (num<0):
print("The entered number is NEGATIVE")
else:
print("The entered number is POSITIVE")
----------------------------------------------------------------------------------------------------------
3. Write a program in Python to accept a number from the user and find whether it is even or odd.
PYTHON PROGRAM:
#PROGRAM TO CHECK WHETHER THE ENTERED NUMBER IS EVEN OR ODD
num=int(input("Enter the number: "))
remain=num%2
if (remain==0):
print("The entered number is EVEN")
else:
print("The entered number is ODD")
----------------------------------------------------------------------------------------------------------
4. Write a program in Python to accept percentage marks obtained by a student and print his grade depending on the following conditions:
Let us look at the IF based questions given in the EXERCISE WORK. We will do so one by one.
------------------------------------------------------------------------------------------------------------------------
Link for the Google Meet class is as follows:
We will try ALL the programs discussed on the Python IDLE environment.
-----------------------------------------------------------------------------------------------------------------------
By the end of this session, you will be able to:
- Understand the systematic development of a program to solve the given problem.
- Apply the concept of Input( ) function to accept values from the user.
- Apply the concept of TYPECASTING
- Apply the variety of IF statements to solve the problem at hand
- Apply the concept of Print( 0 function to display the result
1. WAP to accept the age of the user and check whether he/she can vote or not.
PYTHON PROGRAM:
#PROGRAM TO CHECK WHETHER THE USER CAN VOTE OR NOT
age=int(input("Enter your age: "))
if (age<18):
print("You can not vote")
else:
print("You can vote")
----------------------------------------------------------------------------------------------------------
2. Write a program to accept a number from the user and find whether its is positive, negative or zero using the decision statements.
PYTHON PROGRAM:
#PROGRAM TO CHECK WHETHER THE ENTERED NUMBER IS POSITIVE , NEGATIVE OR ZERO
num=int(input("Enter the number: "))
if (num==0):
print("The entered number is ZERO")
elif (num<0):
print("The entered number is NEGATIVE")
else:
print("The entered number is POSITIVE")
----------------------------------------------------------------------------------------------------------
3. Write a program in Python to accept a number from the user and find whether it is even or odd.
PYTHON PROGRAM:
#PROGRAM TO CHECK WHETHER THE ENTERED NUMBER IS EVEN OR ODD
num=int(input("Enter the number: "))
remain=num%2
if (remain==0):
print("The entered number is EVEN")
else:
print("The entered number is ODD")
----------------------------------------------------------------------------------------------------------
4. Write a program in Python to accept percentage marks obtained by a student and print his grade depending on the following conditions:
if percentage>=90, Grade--> A
if percentage<90 but >=75, Grade--> B
if percentage<75 but >=60, Grade--> C
if percentage<60 but >=45, Grade--> D
if percentage<45 but >33, Grade--> E
else Grade-->F
PYTHON PROGRAM:
#PROGRAM TO ACCEPT THE PERCENTAGE MARKS AND DISPLAY THE GRADE
marks=float(input("Enter the percentage marks obtained: "))
if (marks>=90):
print("Grade- A")
elif (marks<90 and marks >=75):
print("Grade- B")
elif (marks<75 and marks >=60):
print("Grade- C")
elif (marks<60 and marks >=45):
print("Grade- D")
elif (marks<45 and marks >33):
print("Grade- E")
else:
print("Grade-F")
----------------------------------------------------------------------------------------------------------
PYTHON PROGRAM:
#PROGRAM TO ACCEPT THE PERCENTAGE MARKS AND DISPLAY THE GRADE
marks=float(input("Enter the percentage marks obtained: "))
if (marks>=90):
print("Grade- A")
elif (marks<90 and marks >=75):
print("Grade- B")
elif (marks<75 and marks >=60):
print("Grade- C")
elif (marks<60 and marks >=45):
print("Grade- D")
elif (marks<45 and marks >33):
print("Grade- E")
else:
print("Grade-F")
----------------------------------------------------------------------------------------------------------
Good morning mam
ReplyDeleteGOOD MORNING MAM
ReplyDelete-ASHISH
Good morning ma'am
ReplyDelete-Geet
good morning ma'am
ReplyDelete-Artham
Excellent tejas
ReplyDelete