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.

Python program to find the electricity bill

In this python, if-else program, we will calculate the electricity bill according to the units consumed by a consumer. 

There are 4 different per unit electricity bill rate, that we have to consider to calculate the bill.

a). Up to 50 units consumption, the rate is 0.50 Rupee/per unit.
b). Up to 100 units consumption, the rate is 0.70 Rupee/per unit.
c). Up to 250 units consumption,  the rate is 1.25 Rupee/per unit.
d). Above 250 units of consumption, the rate is 1.25 Rupee/per unit.

And additional surcharge of 17% is added to the bill

Steps to solve the program
  1. Take the units consumed by a user as input through the user.
  2. Use for loop with the range function to iterate over units consumed by a user.
  3. Count the total number of units in each category (i.e 0-50,50-100,100-250,250- ) using if-else statements.
  4. Add respective units with their respective charges to bill_amount
  5. Find the sum and add an additional surcharge of 17% to the sum.
  6. Print the output.
				
					total_unit = int(input("Total units Consumed="))
bill_amount = 0

# If each unit we will add to rate amount in total bill amount
for bill_unit in range(1, total_unit+1):
    if bill_unit <= 50:
        bill_amount = bill_amount + 0.50
    elif bill_unit > 50 and bill_amount <= 100:
        bill_amount = bill_amount + 0.75
    elif bill_unit > 100 and bill_amount <= 250:
        bill_amount = bill_amount + 1.25
    elif bill_unit > 250:
        bill_amount = bill_amount + 1.5

# Addition 17% surcharge on total bill amount
bill_amount_sur = bill_amount + bill_amount * (17/100)
print("Bill amount with surcharge :", bill_amount_sur)
				
			

Output :

				
					Total units consumed : 350
Total Bill amount with 17% surcharge : 432.0225
				
			

Related Articles

print all the numbers from 10-15 except 13

check whether a given year is a leap or not.

Program to print all numbers from 10-15 except 13

In this python if else program, we will program to print all numbers from 10-15 except 13

Steps to solve the program
  1. Use for loop with the range function to iterate over all the numbers from 10-15.
  2. During iteration check whether the number is not equal to 13 using an if-else statement.
  3. Print only those numbers.
				
					
for i in range(10,16):
    if i!=13:
        print(i)
				
			

Output :

				
					10
11
12
14
15
				
			

Related Articles

check whether the given input is a string or not.

find the electricity bill.

Program to check whether the input is a string

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

A string is any series of characters that are interpreted literally by a script. For example, “python”

Steps to solve the program
  1. Take input from the user.
  2. Check the type of input by using type().
  3. Check whether the given input is a string using an if-else statement.
  4. Print the output.
				
					str1 = "Hello"

if type(str1) == str:
    print("True")
else:
    print("False")
				
			

Output :

				
					True
				
			

Related Articles

check whether the given number is float or not.

print all the numbers from 10-15 except 13

Program to check whether the number is float

In this python if else program, we will check whether the given number is float or not.

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 any number of your choice as input.
  2. Check the type of the input number by using type().
  3. Check whether the given number is float or not using an if-else statement.
  4. Print the output.
				
					num1 = 12.6

if type(num1) == float:
    print("True")
else:
    print("False")
				
			

Output :

				
					True
				
			

Related Articles

check whether the given number is an integer or not.

check whether the given input is a string or not.

Check whether the number is an integer or not.

In this python if else program, we will check whether the given number is an integer or not.

An Integer is a whole number, which includes negative numbers, positive numbers, and zero. Integers don’t include any fractions or rational parts

Steps to solve the program
  1. Take any number of your choice as input.
  2. Check the type of the input number by using type().
  3. Check whether the given number is an integer or not using an if-else statement.
  4. Print the output.
				
					num1 = 54

if type(num1) == int:
    print("True")
else:
    print("False")
				
			

Output :

				
					True
				
			

Related Articles

check whether the given character is lowercase or not.

check whether the given number is float or not.