LESSON – 1
Detailed Answers:
Q1. Explain features of Python.
Python is a powerful, high-level, interpreted programming language
known for its simplicity and readability. It provides several important
features: 1. **Simple & Readable:** Its English-like syntax makes it easy
for beginners. 2. **Interpreted:** Code runs line-by-line, helping in fast
debugging. 3. **Object-Oriented:** Supports classes, objects,
inheritance, polymorphism. 4. **Platform Independent:** Same program
runs on Windows, Linux, Mac. 5. **Extensive Libraries:** It provides
built-in modules like math, random, OS, Tkinter, etc. 6. **Dynamic
Typing:** Variable types need not be declared. 7. **Embeddable &
Extensible:** Python can be combined with C/C++. 8. **Large
Community Support:** Rich documentation, tutorials, and packages.
Q2. Explain string manipulation.
String manipulation means performing operations on string data. Python
provides powerful string functions such as: • Indexing and slicing for
extracting characters. • Functions like upper(), lower(), title(), replace(),
find(), split(), join(). • Operators such as + (concatenation), *
(repetition). • Checking content using isalpha(), isnumeric(), isdigit().
Strings are immutable, so operations create new strings.
Q3. Explain list in detail.
A list is an ordered collection of items. It is mutable, meaning items can
be changed. Example: l = [10, 20, 'apple'] Features: • Supports indexing
& slicing • Allows duplicates • Methods include append(), insert(),
remove(), pop(), sort(), reverse() Lists are widely used due to flexibility.
Q4. Explain tuple in detail.
Tuples are ordered, immutable collections. They are faster than lists.
Example: t = (1, 2, 3) Uses: • Storing fixed values like days, coordinates.
• Provides methods like count(), index(). Tuples ensure data safety since
values cannot be modified.
Q5. Explain dictionary manipulation.
A dictionary stores data as key-value pairs. Example: d =
{'name':'Kunal', 'age':20} Common operations: • Adding items:
d['city']='Pune' • Updating: [Link]({'age':21}) • Deleting: del d['age']
• Keys & values: [Link](), [Link]() Dictionaries are fast due to
hashing.
Q6. Define function and types of functions.
A function is a block of reusable code defined using 'def'. Types: 1.
Built-in functions (print, len) 2. User-defined functions 3. Lambda
functions (anonymous) 4. Recursive functions
Q7. Explain local & global variables.
Local variables exist only inside a function. Global variables are defined
outside and can be used anywhere. Example: x = 10 (global) def fun(): y
= 20 (local) print(x, y)
LESSON – 2
Detailed Answers:
Q1. What is module and how to create module?
Module = Python file containing variables, functions or classes. Create a
module: [Link] def add(a,b): return a+b Importing: import mymod
Q2. Explain Built-in module.
Python provides preinstalled modules: math, datetime, random, os, sys.
They provide ready-made functions for calculations, system operations,
time handling, etc.
Q3. Define package and how to create package.
A package is a directory containing multiple modules and __init__.py file.
Syntax: mypack/ __init__.py [Link] Import: from mypack import mod1
Q4. Explain predefined package with example.
Examples: • NumPy – numerical computing • Pandas – data analysis •
Matplotlib – data visualization Example: import numpy as np a =
[Link]([1,2,3])