School/Department of
PSIS
Students
Name of the Program(s) of
BCA
Students
Semester/Year II/I
Course Code & Name CSA1503 Programming In Python
MODULE 1: Basics of Python
1. What is Python?
Python is a high-level, interpreted programming language known for its
simplicity and readability. It is widely used for web development, data
analysis, and automation. It supports multiple programming paradigms.
Syntax: print("Hello")
2. What are variables?
Variables are used to store data values in memory. Python does not require
explicit declaration of variable types. The value assigned determines the data
type automatically.
Syntax: x = 10
3. What are data types?
Data types define the type of data a variable can hold, such as integer, float,
or string. They help in performing appropriate operations on data. Python
supports multiple built-in data types.
Syntax: a = 5
4. What is an operator?
Operators are symbols used to perform operations on variables and values.
They include arithmetic, relational, and logical operators. They help in
computations and comparisons.
Syntax: a + b
5. What is a conditional statement?
Conditional statements are used to make decisions based on conditions.
They execute specific blocks of code depending on whether the condition is
true or false.
Syntax: if x > 0:
6. What is a loop?
A loop is used to execute a block of code repeatedly. It reduces redundancy
and improves efficiency in programs. Python supports for and while loops.
Syntax: for i in range(5):
7. Difference between for and while loop?
A for loop is used when the number of iterations is known, while a while
loop is used when the condition controls execution. Both are used for
repetition.
Syntax: while x > 0:
MODULE 2: Functions, Strings, Lists
1. What is a function?
A function is a block of reusable code that performs a specific task. It helps
in reducing code duplication and improving modularity. Functions can take
inputs and return outputs.
Syntax: def add(a, b):
2. What is a string?
A string is a sequence of characters enclosed in quotes. It is used to store
textual data. Strings are immutable, meaning their values cannot be changed
after creation.
Syntax: s = "Python"
3. What is a list?
A list is an ordered collection of elements that can store multiple values.
Lists are mutable, allowing modification of elements. They can contain
different data types.
Syntax: [1, 2, 3]
4. What is list comprehension?
List comprehension is a concise way to create lists in Python. It simplifies
code and improves readability by combining loops and conditions in a single
line.
Syntax: [x for x in range(5)]
5. What is string slicing?
String slicing is used to extract a portion of a string using index positions. It
allows accessing specific parts of the string easily.
Syntax: s[0:3]
6. What is a nested list?
A nested list is a list that contains another list as its element. It is useful for
representing multi-dimensional data such as matrices.
Syntax: [[1,2],[3,4]]
7. Difference between list and string?
A list is mutable and can be modified, whereas a string is immutable and
cannot be changed. Lists can store different data types, while strings store
characters.
Syntax: l[0] = 10
MODULE 3: Data Structures & File Handling
1. What is a tuple?
A tuple is an ordered collection of elements that is immutable. Once created,
its values cannot be changed. It is used for fixed data.
Syntax: (1, 2, 3)
2. What is a dictionary?
A dictionary stores data in key-value pairs. It allows fast access to values
using keys. Keys must be unique.
Syntax: {"name": "Ram"}
3. What is a set?
A set is an unordered collection of unique elements. It does not allow
duplicate values. Sets are useful for mathematical operations.
Syntax: {1, 2, 3}
4. What is file handling?
File handling is used to read and write data to files. It helps in storing data
permanently. Python provides functions to open, read, and write files.
Syntax: open("[Link]","r")
5. What is exception handling?
Exception handling is used to handle runtime errors and prevent program
crashes. It ensures smooth execution of code. It is implemented using try and
except blocks.
Syntax: try:
6. What is a key in dictionary?
A key is used to access a value in a dictionary. Each key must be unique. It
helps in quick retrieval of data.
Syntax: d["name"]
7. Difference between list and tuple?
Lists are mutable and can be modified, whereas tuples are immutable. Lists
are used for dynamic data, while tuples are used for fixed data.
Syntax: (1,2)
MODULE 4: OOP & Data Visualization
1. What is OOP?
Object-Oriented Programming is a programming paradigm based on objects
and classes. It helps in organizing code and improving reusability.
Syntax: class A:
2. What is a class?
A class is a blueprint for creating objects. It defines properties and methods
of an object. Classes help in structuring programs.
Syntax: class Student:
3. What is an object?
An object is an instance of a class. It represents a real-world entity. Objects
use class properties and methods.
Syntax: s = Student()
4. What is encapsulation?
Encapsulation is the process of combining data and methods into a single
unit. It helps in protecting data from unauthorized access.
Syntax: self.x = 10
5. What is inheritance?
Inheritance allows one class to acquire properties and methods of another
class. It promotes code reuse and reduces redundancy.
Syntax: class B(A):
6. What is data visualization?
Data visualization is the graphical representation of data. It helps in
understanding patterns and trends easily.
Syntax: [Link](x,y)
7. Name any visualization library?
Matplotlib is a popular Python library used for creating graphs and charts. It
supports various types of visualizations.
Syntax: import [Link] as plt