FREE E LEARNING PLATFORM
☰ HOMEEXCEPTIONSOOPSJVMINTRO
×

Python Syllabus

AKTU Python Syllabus AKTU Python Freshers AKTU Python Advanced AKTU Pyton PYQ AKTU Pyton PYQS 2026 AKTU Pyton PYQS 2025 AKTU Pyton PYQS 2024

Unit I Introduction

Introduction to Python History of Python Features of Python Applications of Python Python Installation Python IDE Python Program Life Cycle First Python Program Blocks & Indentation Comments Keywords Identifiers Variables Input & Output Data Types Numeric Data Types Type Conversion Python Operators

Unit II Control Statements

if Statement if...else Statement Nested if elif Statement for Loop range() Function while Loop Nested Loops break Statement continue Statement pass Statement else with Loop

Unit III Complex Data Types

Strings String Operations String Methods String Built-in Functions Lists List Slicing List Methods List Built-in Functions Tuples Tuple Methods Dictionaries Dictionary Methods Dictionary Built-in Functions Python Built-in Functions Python Functions User Defined Functions Lambda Functions Recursive Functions

Unit IV File Handling

Introduction to File Handling open() read() readline() readlines() write() writelines() File Pointer seek() tell() File Modes

Unit V Packages & GUI

Modules Packages NumPy Pandas Matplotlib Tkinter Introduction Tkinter Widgets Button Widget Label Widget Entry Widget Frame Widget Menu Widget Event Handling Programming with IDE Tkinter Mini Project

Python Programs

100+ Solved Programs Pattern Programs File Programs Tkinter Programs

AKTU Questions

Unit I Questions Unit II Questions Unit III Questions Unit IV Questions Unit V Questions Viva Questions Python MCQs

Previous Papers

AKTU 2026 (Solved) AKTU 2025 (Solved) AKTU 2024 (Solved) AKTU 2023 (Solved) AKTU 2022 (Solved)
 


Python if-elif-else Statement

The if-elif-else statement is used when a program needs to check multiple conditions. Python checks the conditions from top to bottom and executes the block belonging to the first condition that is True.

The elif keyword means "else if". It allows us to test additional conditions after the initial if condition.

Syntax of if-elif-else

if condition1:
    statement1
elif condition2:
    statement2
else:
    statement3

The if condition is checked first. If it is false, the elif condition is checked. If all conditions are false, the else block is executed.


Simple if-elif Example

marks = 75

if marks >= 90:
    print("Grade A+")
elif marks >= 75:
    print("Grade A")
elif marks >= 60:
    print("Grade B")
else:
    print("Grade C")
Output:
Grade A

Since marks >= 90 is false, Python checks marks >= 75. This condition is true, so the remaining conditions are not checked.


if-elif with User Input

marks = int(input("Enter your marks: "))

if marks >= 90:
    print("Grade A+")
elif marks >= 75:
    print("Grade A")
elif marks >= 60:
    print("Grade B")
elif marks >= 40:
    print("Grade C")
else:
    print("Fail")
Example:
Enter your marks: 82
Grade A

Checking Positive, Negative and Zero

number = int(input("Enter a number: "))

if number > 0:
    print("Positive number")
elif number < 0:
    print("Negative number")
else:
    print("Zero")
Example:
Enter a number: -10
Negative number

Three different possibilities are handled using one if, one elif and one else.


Checking Even and Odd Numbers

number = int(input("Enter a number: "))

if number % 2 == 0:
    print("Even number")
elif number % 2 != 0:
    print("Odd number")
Example:
Enter a number: 15
Odd number

Finding the Greatest of Three Numbers

a = 25
b = 40
c = 30

if a >= b and a >= c:
    print("a is greatest")
elif b >= a and b >= c:
    print("b is greatest")
else:
    print("c is greatest")
Output:
b is greatest

Checking Age Group

age = int(input("Enter your age: "))

if age < 13:
    print("Child")
elif age < 20:
    print("Teenager")
elif age < 60:
    print("Adult")
else:
    print("Senior citizen")
Example:
Enter your age: 25
Adult

if-elif with Strings

day = input("Enter a day: ")

if day == "Monday":
    print("Start of the week")
elif day == "Friday":
    print("Last working day")
elif day == "Sunday":
    print("Holiday")
else:
    print("Regular day")
Example:
Enter a day: Sunday
Holiday

Checking Vowels

ch = input("Enter a character: ")

if ch == "a":
    print("Vowel")
elif ch == "e":
    print("Vowel")
elif ch == "i":
    print("Vowel")
elif ch == "o":
    print("Vowel")
elif ch == "u":
    print("Vowel")
else:
    print("Not a vowel")
Example:
Enter a character: e
Vowel

if-elif with Logical Operators

age = 25
salary = 40000

if age < 18:
    print("Not eligible")
elif age >= 18 and salary >= 30000:
    print("Eligible")
else:
    print("Conditions not satisfied")
Output:
Eligible

Multiple elif Conditions

Python allows multiple elif statements in a single conditional structure.

marks = 68

if marks >= 90:
    print("Excellent")
elif marks >= 80:
    print("Very Good")
elif marks >= 70:
    print("Good")
elif marks >= 60:
    print("Average")
elif marks >= 40:
    print("Pass")
else:
    print("Fail")
Output:
Average

if-elif without else

The else block is optional. An if-elif structure can be used without an else.

number = 10

if number == 5:
    print("Number is 5")
elif number == 10:
    print("Number is 10")
Output:
Number is 10

First True Condition is Executed

When multiple conditions are true, Python executes only the first true condition and skips the remaining elif and else blocks.

number = 20

if number > 0:
    print("Positive")
elif number > 10:
    print("Greater than 10")
else:
    print("Other")
Output:
Positive

Both conditions are true, but only the first if block is executed.


Order of Conditions

The order of conditions is important in an if-elif-else statement. More specific or higher-priority conditions should generally be checked before broader conditions.

marks = 85

if marks >= 90:
    print("A+")
elif marks >= 75:
    print("A")
elif marks >= 60:
    print("B")
else:
    print("C")
Output:
A

Practical Example: Electricity Bill

units = int(input("Enter units consumed: "))

if units <= 100:
    print("Low consumption")
elif units <= 200:
    print("Medium consumption")
elif units <= 500:
    print("High consumption")
else:
    print("Very high consumption")
Example:
Enter units consumed: 250
High consumption

Practical Example: Calculator

a = 20
b = 5
operator = "*"

if operator == "+":
    print(a + b)
elif operator == "-":
    print(a - b)
elif operator == "*":
    print(a * b)
elif operator == "/":
    print(a / b)
else:
    print("Invalid operator")
Output:
100

Practical Example: Student Result

marks = int(input("Enter marks: "))

if marks >= 75:
    print("Distinction")
elif marks >= 60:
    print("First Division")
elif marks >= 50:
    print("Second Division")
elif marks >= 40:
    print("Pass")
else:
    print("Fail")
Example:
Enter marks: 72
First Division

Difference between if, elif and else

Keyword Purpose
if Checks the first condition.
elif Checks another condition when the previous condition is false.
else Executes when all preceding conditions are false.

if-elif-else vs Nested if

if-elif-else Nested if
Checks multiple alternative conditions. Places one decision inside another decision.
Conditions are checked sequentially. The inner condition depends on the outer condition.
Useful for selecting one option from several alternatives. Useful when a second decision is required after the first decision.

Important Points

  • elif stands for else if.
  • Multiple elif blocks can be used.
  • The else block is optional.
  • Conditions are checked from top to bottom.
  • Only the first true condition is executed.
  • Once a condition is true, the remaining conditions are skipped.
  • Proper indentation is required.
  • The colon : is required after if, elif and else.
Key Point: The if-elif-else statement is used when a program needs to choose one action from multiple possible conditions. Python executes the block belonging to the first condition that evaluates to True.