Python Syllabus Detailed Explanation
Python Syllabus Detailed Explanation
UNIT III
Dictionaries in Python
Dictionaries are collections of key-value pairs where keys must be unique and immutable. They are
print(students["Alice"]) # Output: 90
if "Alice" in students:
Modules in Python
Modules allow you to organize code into reusable files. You can execute modules as scripts, define reusable
# my_module.py
def greet(name):
import my_module
if __name__ == "__main__":
Python provides robust error and exception handling using try-except blocks. This ensures the program can
try:
result = 10 / 0
except ZeroDivisionError as e:
finally:
print("Execution completed.")
UNIT IV
Classes are blueprints for creating objects. They define attributes and methods shared by all objects created
class Car:
Python Programming: Detailed Explanation
self.make = make
self.model = model
def drive(self):
Inheritance
Inheritance allows a class to inherit attributes and methods from a parent class. This promotes code reuse
and organization.
class Parent:
def greet(self):
class Child(Parent):
def greet(self):
super().greet()
child = Child()
child.greet()
# Output:
UNIT V
Tkinter is Python's built-in library for creating graphical user interfaces (GUIs). It provides widgets like Labels,
def on_click():
print("Button clicked!")
root = Tk()
root.mainloop()
Turtle Graphics
Turtle is a module for creating simple graphics, often used for educational purposes. It allows you to draw
t = Turtle()
s = Screen()
# Drawing a square
for _ in range(4):
Python Programming: Detailed Explanation
t.forward(100)
t.right(90)
s.mainloop()