Round up the number to 2 decimal places.

In this python if else program, we will round up the number to 2 decimal places if the number is a float.

Float number:
A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed.

Steps to solve the program
  1. Take a number as input.
  2. Using an if-else statement check the type of the number using type().
  3. If the type of the number is a float then round up the number to 2 decimal places using the round() function.
  4. Else print the number as it.
				
					num = 25.3614

if type(num) == float:
    print(round(num,2))
else:
    print(num)
				
			

Output :

				
					25.36
				
			

Related Articles

reads month and returns season for that month.

check whether the input number is divisible by 12 or not.

Read month and returns season for that month.

In this python if else program, we will read month and returns season for that month.

Condition for the season:
Summer – February, March, April, May
Rainy – June, July, August, September
Winter – Octomber, November, December, January

Steps to solve the program
  1. Read the month from the user.
  2. Using an if-else statement print the season for the input month
				
					month = input("Enter a month: ")

if month == "February" or month == "March" or month == "April" or month == "May":
    print("Summer")
elif month == "June" or month == "July" or month == "August" or month == "September":
    print("Rainy")
else:
    print("Winter")
				
			

Output :

				
					Enter a month: February
Summer
				
			

Related Articles

check whether a triangle is isosceles or not.

check whether the input number is a float or not if yes then round up the number to 2

Check whether a triangle is isosceles or not.

In this python if else program, we will check whether a triangle is isosceles or not depending on the lengths of the sides.

An isosceles triangle is a triangle with (at least) two equal sides.

Steps to solve the program
  1. Take 3 sides of the triangle as input through the user.
  2. If any two sides of the triangle are equal then the triangle is an isosceles triangle.
  3. Use an if-else statement to check this.
  4. Print the output.
				
					s1 = int(input("Enter length of side 1: "))
s2 = int(input("Enter length of side 2: "))
s3 = int(input("Enter length of side 3: "))

if s1 == s2 or s2 == s3 or s1 == s3:
    print("It is an isosceles triangle")
else:
    print("It is not an isosceles triangle")
				
			

Output :

				
					Enter length of side 1: 10
Enter length of side 2: 15
Enter length of side 3: 10
It is an isosceles triangle
				
			

Related Articles

check whether a triangle is scalene or not.

reads month and returns season for that month.

Program to check whether a triangle is a scalene

In this python if else program, we will check whether a triangle is scalene or not depending on the side lengths.

A scalene triangle is a triangle in which all three sides are in different lengths, and all three angles are of different measures. However, the sum of all the interior angles is always equal to 180 degrees.

Steps to solve the program
  1. Take 3 sides of the triangle as input through the user.
  2. If all three sides of the triangle are not equal then the triangle is a scalene triangle.
  3. Use an if-else statement to check this.
  4. Print the output.
				
					s1 = int(input("Enter length of side 1: "))
s2 = int(input("Enter length of side 2: "))
s3 = int(input("Enter length of side 3: "))

if s1 != s2 != s3:
    print("It is a scalane triangle")
else:
    print("It is not a scalane triangle")
				
			

Output :

				
					Enter length of side 1: 10
Enter length of side 2: 15
Enter length of side 3: 18
It is an scalane triangle
				
			

Related Articles

check whether a triangle is equilateral or not.

check whether a triangle is isosceles or not.

Check whether a triangle is equilateral or not

In this pytho if else program, we will program to check whether a triangle is equilateral or not. An equilateral triangle is a triangle with all three sides of equal length

Steps to solve the program
  1. Take 3 sides of the triangle as input through the user.
  2. If all three sides of the triangle are equal then the triangle is an equilateral triangle.
  3. Use an if-else statement to check this.
  4. Print the output.
				
					s1 = int(input("Enter length of side 1: "))
s2 = int(input("Enter length of side 2: "))
s3 = int(input("Enter length of side 3: "))

if s1 == s2 == s3:
    print("It is an equilateral triangle")
else:
    print("It is not an equilateral triangle")
				
			

Output :

				
					Enter length of side 1: 15
Enter length of side 2: 15
Enter length of side 3: 15
It is an equilateral triangle
				
			

Related Articles

convert the month name to the number of days.

check whether a triangle is scalene or not.

Convert the month name to the number of days.

In this python if else program, we will convert the month name to the number of days.

Steps to solve the program
  1. Take the month name as input through the user.
  2. Print the number of days according to the input month using if-else statements.
				
					month = input("Enter month: ").lower()

if month == "january":
    print("Number of days: 31")
elif month == "february":
    print("Number of days: 28/29")
elif month == "march":
    print("Number of days: 31")
elif month == "april":
    print("Number of days: 30")
elif month == "may":
    print("Number of days: 31")
elif month == "june":
    print("Number of days: 30")
elif month == "july":
    print("Number of days: 31")
elif month == "august":
    print("Number of days: 31")
elif month == "september":
    print("Number of days: 30")
elif month == "october":
    print("Number of days: 31")
elif month == "november":
    print("Number of days: 30")
elif month == "december":
    print("Number of days: 31")
else:
    print("Invalid month")
				
			

Output :

				
					Enter month: February
Number of days: 28/29
				
			

Related Articles

check whether an alphabet is a consonant.

check whether a triangle is equilateral or not.

Program to check whether an alphabet is a consonant.

In this python if else program, we will check whether an alphabet is a consonant.

Consonant:  A consonant is a speech sound that is not a vowel. Consonants are all the non-vowel sounds

Steps to solve the program
  1. Take an alphabet as input through the user.
  2. Create a list of vowels.
  3. Using an if-else statement check whether the input alphabet is in the list or not.
  4. Print the output.
				
					char = input("Enter a character: ")
vowel = ["A","E","I","O","U","a","e","i","o","u"]

if char not in vowel:
    print("True")
else:
    print("False")
				
			

Output :

				
					Enter a character: B
True
				
			

Related Articles

check whether an alphabet is a vowel.

convert the month name to the number of days.

Program to check whether an alphabet is a vowel

In this python if else program, we will check whether an input alphabet is a vowel or not.

Vowel: A speech sound produced without obstruction or audible friction in the mouth. : a letter (as a, e, i, o, u, and sometimes y) representing a vowel.

Steps to solve the program
  1. Take an alphabet as input through the user.
  2. Create a list of vowels.
  3. Using an if-else statement check whether the input vowel is in the list or not.
  4. Print the output.
				
					char = input("Enter a character: ")
vowel = ["A","E","I","O","U","a","e","i","o","u"]

if char in vowel:
    print("True")
else:
    print("False")
				
			

Output :

				
					Enter a character: A
True
				
			

Related Articles

Fizz-Buzz program.

check whether an alphabet is a consonant.

Python if else program to print Fizz-Buzz

In this python if else program, we will check whether the number id divided by the numbers are given in the question and print FIzz-Buzz according to it.

Steps to solve the program
  1. Take a number as input through the user.
  2. If a multiple of two print “Fizz” instead of the number and for the multiples of three print “Buzz”.
  3. For numbers that are multiples of both two and three print “FizzBuzz”.
  4. Use if-else statements for this purpose.
				
					num = int(input("Enter a number: "))

if num%2 == 0 and num%3 == 0:
    print("FizzBuzz")
elif num%2 == 0:
    print("Fizz")
elif num%3 == 0:
    print("Buzz")
				
			

Output :

				
					Enter a number: 6
FizzBuzz
				
			

Related Articles

check whether a given year is a leap or not.

check whether an alphabet is a vowel.

Python program to check whether a year is a leap

In this python, if else program, we will check whether a given year is a leap or not.

Leap Year: A year, occurring once every four years, which has 366 days including 29 February as an intercalary day. A Century year is a leap year only if it is perfectly divisible by 400.

Steps to solve the program
  1. Take a year as input through the user.
  2. Use the following conditions to check whether a year is a leap or not. a)year%100 != 0 or year%400 == 0, b) year%4 == 0.
  3. Use an if-else statement for this purpose.
  4. Print the output. 
				
					year = int(input("Enter the year: "))

if (year%100 != 0 or year%400 == 0) and year%4 == 0:
    print("The given year is leap year.")
else:
    print("The given year is not leap year.")
				
			

Output :

				
					Enter the year: 2000
The given year is leap year.
				
			

Related Articles

find the electricity bill.

Fizz-Buzz program.