📚 Modules
Python Fundamentals
Learn the building blocks of Python programming — variables, data types, and operators.
📖 Study Material
Python is a high-level, interpreted programming language known for its simplicity and readability. Created by Guido van Rossum in 1991, Python has become one of the most popular languages worldwide.
Why Learn Python?
- Easy to learn and read — great for beginners
- Used in Web Development, Data Science, AI, Automation
- Large community and extensive libraries
- High demand in the job market
# This is your first Python program
print("Hello, World!")
print("Welcome to UKTekIndia!")
# Output:
# Hello, World!
# Welcome to UKTekIndia!
Variables are containers for storing data. In Python, you don't need to declare the type — Python figures it out automatically.
Basic Data Types:
- int — Integer numbers: 5, -3, 100
- float — Decimal numbers: 3.14, -0.5
- str — Text strings: "Hello", 'Python'
- bool — True or False
# Creating variables
name = "Rahul" # str
age = 25 # int
height = 5.9 # float
is_student = True # bool
# Printing variables
print(f"Name: {name}")
print(f"Age: {age}")
print(f"Type of age: {type(age)}")
# Output:
# Name: Rahul
# Age: 25
# Type of age: <class 'int'>
Operators are symbols that perform operations on variables and values.
Types of Operators:
- Arithmetic: +, -, *, /, //, %, **
- Comparison: ==, !=, >, <, >=, <=
- Logical: and, or, not
- Assignment: =, +=, -=, *=
# Arithmetic operators
a = 10
b = 3
print(a + b) # 13
print(a - b) # 7
print(a * b) # 30
print(a / b) # 3.333...
print(a // b) # 3 (floor division)
print(a % b) # 1 (remainder)
print(a ** b) # 1000 (power)
# Comparison
print(a > b) # True
print(a == b) # False
Python uses input() to take user input and print() to display output.
# Taking input from user
name = input("Enter your name: ")
age = int(input("Enter your age: "))
# Displaying output
print(f"Hello {name}! You are {age} years old.")
# String formatting methods
print("Name: %s, Age: %d" % (name, age))
print("Name: {}, Age: {}".format(name, age))
📝 Class 1 Exam
Test your understanding of Python Fundamentals. You need 70% to pass.
Control Flow & Loops
Learn how to control the flow of your program using conditions and loops.
📖 Study Material
Conditional statements allow you to execute code based on whether a condition is True or False.
age = 18
if age >= 18:
print("You are an adult!")
elif age >= 13:
print("You are a teenager!")
else:
print("You are a child!")
# Nested condition
marks = 85
if marks >= 90:
grade = "A+"
elif marks >= 80:
grade = "A"
elif marks >= 70:
grade = "B"
else:
grade = "C"
print(f"Your grade: {grade}")
The for loop iterates over a sequence (list, string, range, etc.).
# Looping through a range
for i in range(1, 6):
print(f"Number: {i}")
# Looping through a list
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(f"I like {fruit}")
# Using enumerate
for index, fruit in enumerate(fruits):
print(f"{index}: {fruit}")
The while loop repeats as long as a condition is True.
# Basic while loop
count = 1
while count <= 5:
print(f"Count: {count}")
count += 1
# While with break
while True:
answer = input("Type 'quit' to exit: ")
if answer == "quit":
break
print(f"You typed: {answer}")
These keywords control loop execution flow.
- break — Exits the loop immediately
- continue — Skips current iteration
- pass — Does nothing (placeholder)
# Using break
for i in range(10):
if i == 5:
break
print(i) # 0, 1, 2, 3, 4
# Using continue
for i in range(10):
if i % 2 == 0:
continue
print(i) # 1, 3, 5, 7, 9
📝 Class 2 Exam
Test your knowledge of Control Flow & Loops. You need 70% to pass.
Functions & Modules
Learn to write reusable code with functions and organize code with modules.
📖 Study Material
Functions are blocks of reusable code that perform a specific task.
# Basic function
def greet(name):
return f"Hello, {name}!"
print(greet("Rahul")) # Hello, Rahul!
# Default parameters
def power(base, exp=2):
return base ** exp
print(power(3)) # 9
print(power(3, 3)) # 27
# Multiple return values
def get_stats(numbers):
return min(numbers), max(numbers), sum(numbers)/len(numbers)
low, high, avg = get_stats([10, 20, 30, 40])
print(f"Min: {low}, Max: {high}, Avg: {avg}")
Use *args for variable positional arguments and **kwargs for keyword arguments.
# *args - variable arguments
def total(*args):
return sum(args)
print(total(1, 2, 3, 4)) # 10
# **kwargs - keyword arguments
def info(**kwargs):
for key, value in kwargs.items():
print(f"{key}: {value}")
info(name="Priya", age=22, city="Kolkata")
Lambda functions are small anonymous functions defined in a single line.
# Lambda function
square = lambda x: x ** 2
print(square(5)) # 25
# Lambda with sorted
students = [("Rahul", 85), ("Priya", 92), ("Amit", 78)]
sorted_students = sorted(students, key=lambda s: s[1], reverse=True)
print(sorted_students)
# [('Priya', 92), ('Rahul', 85), ('Amit', 78)]
📝 Class 3 Exam
Test your knowledge of Functions & Modules.
OOP Concepts
Master Object-Oriented Programming — classes, objects, inheritance, and more.
📖 Study Material
A class is a blueprint for creating objects. Objects have properties (attributes) and behaviors (methods).
class Student:
def __init__(self, name, age):
self.name = name
self.age = age
def introduce(self):
return f"Hi, I'm {self.name}, age {self.age}"
# Creating objects
s1 = Student("Rahul", 20)
s2 = Student("Priya", 22)
print(s1.introduce()) # Hi, I'm Rahul, age 20
Inheritance allows a child class to inherit properties from a parent class.
class Animal:
def __init__(self, name):
self.name = name
def speak(self):
return "..."
class Dog(Animal):
def speak(self):
return f"{self.name} says: Woof!"
class Cat(Animal):
def speak(self):
return f"{self.name} says: Meow!"
dog = Dog("Buddy")
cat = Cat("Whiskers")
print(dog.speak()) # Buddy says: Woof!
print(cat.speak()) # Whiskers says: Meow!
📝 Class 4 Exam
Test your OOP knowledge.
Data Structures
Master Python's built-in data structures — Lists, Dictionaries, Sets, and Tuples.
📖 Study Material
Lists are mutable ordered collections. Tuples are immutable.
# Lists (mutable)
fruits = ["apple", "banana", "cherry"]
fruits.append("mango")
fruits.remove("banana")
print(fruits) # ['apple', 'cherry', 'mango']
# List comprehension
squares = [x**2 for x in range(1, 6)]
print(squares) # [1, 4, 9, 16, 25]
# Tuples (immutable)
coords = (10, 20)
print(coords[0]) # 10
Dictionaries store key-value pairs. Sets store unique values.
# Dictionary
student = {"name": "Rahul", "age": 20, "grade": "A"}
print(student["name"]) # Rahul
student["city"] = "Kolkata" # Add new key
# Sets
numbers = {1, 2, 3, 4, 5, 5, 3}
print(numbers) # {1, 2, 3, 4, 5} - unique only
# Set operations
a = {1, 2, 3}
b = {3, 4, 5}
print(a | b) # Union: {1, 2, 3, 4, 5}
print(a & b) # Intersection: {3}
📝 Class 5 Exam
Test your Data Structures knowledge.
File Handling & Error Handling
Learn to work with files and handle errors gracefully in Python.
📖 Study Material
Python provides built-in functions to read, write, and manage files.
# Writing to a file
with open("notes.txt", "w") as f:
f.write("Hello, World!\n")
f.write("Python is awesome!")
# Reading from a file
with open("notes.txt", "r") as f:
content = f.read()
print(content)
# Appending to a file
with open("notes.txt", "a") as f:
f.write("\nNew line added!")
Error handling prevents your program from crashing unexpectedly.
try:
number = int(input("Enter a number: "))
result = 10 / number
print(f"Result: {result}")
except ValueError:
print("Error: Please enter a valid number!")
except ZeroDivisionError:
print("Error: Cannot divide by zero!")
finally:
print("This always executes.")
📝 Class 6 Exam
Test your File Handling & Error Handling knowledge.