Check the student’s eligibility to attend the exam

In this python if else program, we will check the student’s eligibility to attend the exam based on his/her attendance.

Steps to solve the program
  1. Take a student’s attendance % as input through the user.
  2. Using an if-else statement check the student’s eligibility to attend the exam.
  3. If the attendance is greater than or equal to 75 then the student is eligible, else the student is not eligible.
  4. Print the respective output.
				
					attendance = int(input("Enter attendance % of a student: "))

if attendance >= 75:
    print("Student is eligible")
else:
    print("Student is not eligible")
				
			

Output :

				
					Enter attendance % of a student: 78
Student is eligible
				
			

Related Articles

print the absolute value of a number defined by the user.

check whether the last digit of a number defined by the user is divisible by 4 or not.

Program to print the absolute value of a number

In this python if else program, we will print the absolute value of a number. If the number is negative then print its absolute value, else print the number.

Absolute value: The absolute value of a real number a is the non-negative value of a without regard to its sign.

Steps to solve the program
  1. Take a number as input through the user.
  2. Using an if-else statement check whether the input number is positive or negative.
  3. If the number is negative print its absolute value by using abs(),else print the number.
  4. Print the output.
				
					num = int(input("Enter a number: "))

if num<0:
    print("Absolute value of the number: ",abs(num))
else:
    print("Absolute value of the number: ",num)
				
			

Output :

				
					Enter a number: -1
Absolute value of the number:  1
				
			

Related Articles

Calculate the discount based on the bill.

check the student’s eligibility to attend the exam based on his/her attendance.

Python program to calculate the discount based on the bill.

In this python if else program, we will calculate the discount on the amount based on the bill.

Steps to solve the program
  1. Take the bill amount as input through the user and create a variable and assign its value equal to 0.
  2. Using an if-else statement find how much discount is applicable (i.e. 10% discount if the bill is more than 1000, and 20% if the bill is more than 2000).
  3. Calculate the discount using the formula discount %*(bill amount/100) and store the result in the variable that we have created at the beginning of the program.
  4. Print the output.
				
					bill = int(input("Enter bill amount: "))
discount = 0

if bill >= 2000:
    discount = 20*(bill/100)
elif 1000<= bill < 2000:
    discount = 10*(bill/100)
    
print("Discount amount: ",discount)
				
			

Output :

				
					Enter bill amount: 1500
Discount amount:  150.0
				
			

Related Articles

check if the input shape is sqaure or not.

print the absolute value of a number defined by the user.

Program to check whether the given shape is square

In this python if else program we will, take values of the length and breadth of a rectangle from the user and check if the shape is square or not.

Rectangle: A rectangle is a type of quadrilateral, whose opposite sides are equal and parallel.

Steps to solve the program
  1. Take the length and breadth of the rectangle as input.
  2. The area of the square is the side’s square and the area of a rectangle is length*breadth.
  3. Using an if-else statement check whether both of these values are equal or not.
  4. Print the respective output.
				
					length = int(input("Enter length: "))
breadth = int(input("Enter breadth: "))

if length**2 == length*breadth:
    print("It is a square")
else:
    print("It is not a sqaure")
				
			

Output :

				
					Enter length: 5
Enter breadth: 4
It is not a sqaure
				
			

Related Articles

find employees eligible for bonus..

Calculate the discount based on the bill.

Find employees eligible for bonus based on years served

In this python if else program, we will find the employees eligible for bonus within a company based on years served.

Condition for eligibility:
If an employee has served more or equal to 5 years in the company then only an employee is eligible for bonus.

Steps to solve the program
  1. Take years served within a company by an employee as input.
  2. Use an if-else statement to check the eligibility of an employee.
  3. Use the criteria given in the question.
  4. Print the respective output.
				
					exp = float(input("Enter years served"))

if exp > 4:
    print("You are eligible for bonus")
else:
    print("Your are not eligible for bonus")
				
			

Output :

				
					Enter years served: 5
You are eligible for bonus
				
			

Related Articles

find out given input belongs to which group

check if the input shape is square or not

Find out given input belongs to which group

In this python nested if else program, we will find out given input belongs to which group.

Steps to solve the program
  1. Take a number between 1-100 as input through the user.
  2. Create 10 groups of numbers between 1-10. Each group will have 10 numbers (i.e. 1-10,11-20,….,91-100) using nested if-else statements.
  3. With the help of nested if-else statements check the input number lies in which group.
  4. Print the respective output.
				
					num = int(input("Enter a number: "))

if 1<= num <=10:
    print("The given number belongs to 1st group")
elif 11<= num <=20:
    print("The given number belongs to 2nd group")
elif 21<= num <=30:
    print("The given number belongs to 3rd group")
elif 31<= num <=40:
    print("The given number belongs to 4th group")
elif 41<= num <=50:
    print("The given number belongs to 5th group")
elif 51<= num <=60:
    print("The given number belongs to 6th group")
elif 61<= num <=70:
    print("The given number belongs to 7th group")
elif 71<= num <=80:
    print("The given number belongs to 8th group")
elif 81<= num <=90:
    print("The given number belongs to 9th group")
elif 91<= num <=100:
    print("The given number belongs to 10th group")
else:
print("Invalid number")
				
			

Output :

				
					Enter a number: 36
The given number belongs to 4th group
				
			

Related Articles

check the eligibility of a person to sit on a roller coaster ride or not.

find employees eligible for bonus.

Check the eligibility of a person to sit on a roller coaster ride

In this python if else program we will, check the eligibility of a person to sit on a roller coaster ride according to his/her age.

Codition for eligibility:
Age is greater than 12 then only person is eligible.

Steps to solve the program
  1. Take age as input through the user.
  2. Using an if-else statement check the eligibility of a person. 
  3. If the age is greater than or equal to 12 only then is the person eligible.
  4. Print the respective output.
				
					age = int(input("Enter the age of a person: "))

if age >= 12:
    print("You are eligible")
else:
    print("You are not eligible");
				
			

Output :

				
					Enter the age of a person: 15
You are eligible
				
			

Related Articles

check whether the given input is a dictionary or not.

find out given input belongs to which group

Check whether the given input is a dictionary.

In this python if else program, we will check whether the given input is a dictionary or not.

Dictionary:
A dictionary is a general-purpose data structure for storing a group of objects. A dictionary has a set of keys and each key has a single associated value.

Steps to solve the program
  1. Take input from the user.
  2. Using an if-else statement check whether the given input is a dictionary type or not.
  3. Print the output.
				
					iput = {'name':'Virat','sport':'cricket'}

if type(iput) == dict:
    print("True")
else:
    print("False")
				
			

Output :

				
					True
				
			

Related Articles

check whether the given input is List or not.

check the eligibility of a person to sit on a roller coaster ride or not.

Check whether the given input type is List or not

check whether the given input is Boolean type or not.

check whether the given input is a dictionary or not.

Check whether the given input is Boolean type.

In this python if else program, we will check whether the given input is Boolean type or not.

Boolean expression:
A Boolean expression is a logical statement that is either TRUE or FALSE . Boolean expressions can compare data of any type as long as both parts of the expression have the same basic data type.

Steps to solve the program
  1. Take input through the user.
  2. Using an if-else statement check whether the given input is a Boolean type or not.
  3. Print the output.
				
					num = True

if type(num) == bool:
    print("True")
else:
    print("False")
				
			

Output :

				
					True
				
			

Related Articles

check whether the given input is a complex type or not.

check whether the given input is List or not.