Q1. Why Python?
Definition:
Python is a Object-Oriented ,high-level, interpreted, general-purpose programming language
known for its simplicity, readability, and versatility.
Reasons why Python is used:
1. Simple & Easy to Learn: Python uses English-like syntax, making it beginner-friendly.
2. Open-Source & Free: Anyone can download and use it without cost.
3. Interpreted Language: Code is executed line by line, making debugging easy.
4. Portable: Python code can run on multiple platforms (Windows, Mac, Linux) without
modification.
5. Extensive Libraries: Python has rich libraries like NumPy, Pandas, TensorFlow, etc.
6. Object-Oriented & Procedural: Supports multiple programming paradigms.
Q2. Applications of Python
Definition:
Python has a wide range of applications across different industries and fields.
Major Applications:
1. Web Development – Frameworks like Django, Flask are used to build websites.
2. Data Science & Analytics – Libraries like Pandas, NumPy, Matplotlib help in analyzing and
visualizing data.
3. Machine Learning & AI – Libraries like TensorFlow, PyTorch, Scikit-learn.
4. Automation & Scripting – Automates repetitive tasks (file handling, testing, web scraping).
5. Game Development – Used in games with Pygame library.
6. Cybersecurity & Hacking Tools – Used for penetration testing, scanning, and cryptography.
7. Desktop Applications – GUI apps can be made with Tkinter, PyQt.
8. Networking & IoT – For socket programming and IoT device control.
9. Education & Research – Preferred language for teaching programming.
10.Finance & Fintech – Algorithmic trading, risk analysis, fraud detection.
Q3. Versions of Python
Definition:
Python has gone through multiple versions, each improving performance, security, and adding new
features.
Main Versions:
1. Python 1.x (1991 – 2000):
○ First release by Guido van Rossum.
○ Basic functionality only, not widely used today.
2. Python 2.x (2000 – 2020):
○ Introduced many features like list comprehensions, garbage collection.
○ Popular for a long time but officially discontinued in 2020.
○ Last release: Python 2.7.
3. Python 3.x (2008 – Present):
○ Current and future of Python.
○ Not backward compatible with Python 2.
○ Features: Better Unicode support, f-strings, async/await, type hints.
○ Latest stable version (as of 2025): Python 3.12.x.
Important Note:
● Today, Python 3 is the standard version used in industry, education, and projects.
● Python 2 is obsolete.
Import sys
print(sys.verson)
Number System
● Decimal (Base 10): Normal numbers → 0–9
● Binary (Base 2): 0 & 1
● Octal (Base 8): 0–7
● Hexadecimal (Base 16): 0–9 & A–F
Literals / Variables
● Literal → Fixed value (10, "Hello")
● Variable → Named storage (x = 10)
Example :
x = 100 # variable
y = "Python" # variable
print(x, y) # literal
Data Types
● int → Integer
● float → Decimal number
● str → String
● bool → True/False
● list, tuple, set, dict → Collection types
_____________________________
List Ordered, mutable (can change elements)
Tuple Ordered, immutable (cannot change elements)
Set Unordered, unique elements only (no duplicates)
Dict Stores key-value pairs
_________________________________
Example :
a = 10
b = 3.14
c = "Hello" or ‘my name is vanshika’
d = True
_________________
# Example: List
fruits = ["apple", "banana", "mango", "apple"]
print(fruits) # ['apple', 'banana', 'mango', 'apple']
print(fruits[1]) # banana
fruits[2] = "grapes" # modify element
fruits.append("kiwi") # add new element
print(fruits) # ['apple', 'banana', 'grapes', 'apple']
# Example: Tuple
colors = ("red", "green", "blue", "green")
print(colors) # ('red', 'green', 'blue', 'green')
print(colors[0]) # red
# colors[1] = "yellow" # ❌ ERROR (cannot modify)
# Example: Set
numbers = {1, 2, 3, 2, 4,”h”}
print(numbers) # {1, 2, 3, 4} (duplicates removed)
numbers.add(5)
numbers.remove(2)
print(numbers) # {1, 3, 4, 5,”h”}
# Example: Dictionary
student = { "name": "vanshika",
"age": 17,
"course": "BCA"}
print(student["name"]) # vanshika
student["age"] = 17 # modify value
student["city"] = "delhi" # add new key-value
print(student)
# {'name': 'vanshika', 'age': 17, 'course': 'BCA', 'city': 'delhi'}
Operators
● Arithmetic: + - * / % // **
● Comparison: == != > < >= <=
● Logical: and or not
● Assignment: = += -= *=
● Membership: in, not in
Control Structures – if/else
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
if/elif/else
marks = 85
if marks >= 90:
print("Grade A")
elif marks >= 75:
print("Grade B")
else:
print("Grade C")
Nested if/else
num = 15
if num > 0:
if num % 2 == 0:
print("Positive Even")
else:
print("Positive Odd")
else:
print("Negative or Zero")
Lists / Nested Lists
fruits = ["apple", "banana", "mango"]
nested = [[1, 2], [3, 4], [5, 6]]
print(fruits[0])
print(nested[1][1])
Tuple
● Ordered, immutable collection
● Uses ()
my_tuple = (10, 20, 30)
print(my_tuple[1])
__________________________________________________________