python unit 1 to 5
python unit 1 to 5
1 Introduction to Python
1. What is Python?
Python is a high-level, interpreted programming language used for general-purpose
programming.
Conditional Statements
Loops
my_list[1] = 10
del my_list[2]
2.2 Tuple
my_tuple = (1, 2, 3)
print(my_tuple[0])
🔹 2.3 Set
my_set = {1, 2, 3}
2.4 Dictionary
my_dict['age'] = 26
del my_dict['age']
3.1 Functions
def greet():
print("Hello!")
greet()
3.2 Modules
Ans: OOP is a programming style where everything is grouped into objects and classes to make code
reusable and organized.
Ans: A constructor is a special method called __init__() that runs automatically when an object is
created.
. What is polymorphism?
Ans: It means one function or method can behave in different ways. Example: Same method name
doing different tasks.
Ans: Defining multiple methods with the same name but different parameters (Python does not
support it directly like Java, but can be done using default values).
Ans: When a child class changes the behavior of a method from its parent class.
Ans: Hiding internal details and showing only necessary parts using private variables or methods
(with _ or __ prefix).
Ans: One class can use properties and methods of another class.
🔸 Types of Inheritance:
Unit – V
5.1 Pandas
5. What is Tkinter?
Ans: Tkinter is Python’s built-in library for creating Graphical User Interfaces (GUI).
import tkinter as tk
win = tk.Tk()
win.mainloop()