0% found this document useful (0 votes)
14 views4 pages

Python Basics: Problem Solving & OOP

The document outlines a comprehensive curriculum on Python programming and computational problem solving, divided into five units. Each unit contains a variety of questions categorized into 2-mark, 5-mark, and 10-mark sections, covering topics such as control structures, functions, recursion, object-oriented programming, and file handling. The questions are designed to assess understanding and application of Python concepts, algorithms, and data structures.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Python Basics: Problem Solving & OOP

The document outlines a comprehensive curriculum on Python programming and computational problem solving, divided into five units. Each unit contains a variety of questions categorized into 2-mark, 5-mark, and 10-mark sections, covering topics such as control structures, functions, recursion, object-oriented programming, and file handling. The questions are designed to assess understanding and application of Python concepts, algorithms, and data structures.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

UNIT I — INTRODUCTION TO PYTHON & COMPUTATIONAL PROBLEM SOLVING

🔹 2-Mark Questions
1. What is computational problem solving?
2. What are the limits of computational problem solving?
3. Define an algorithm.
4. What is the role of computer hardware in problem solving?
5. What is the role of computer software in computational problem solving?
6. What are literals in Python?
7. Define variables and identifiers.
8. What are the rules for naming identifiers in Python?
9. List any four basic data types in Python.
10. What is the use of the input() and print() functions?
11. What are operators? Give examples.
12. Define an expression in Python.
13. What is the difference between integer and floating-point division in Python?
14. What is type conversion?
15. What is meant by dynamic typing in Python?

🔹 5-Mark Questions
1. Explain the essence and limits of computational problem solving.
2. Explain the role of computer algorithms in computational problem solving.
3. Describe the structure of a Python program with an example.
4. Explain literals, variables, and identifiers with examples.
5. Explain different types of operators in Python.
6. Write short notes on expressions and data types in Python.
7. Explain the input and output operations in Python.

🔹 10-Mark Questions
1. Explain in detail the process of computational problem solving.
2. Explain the architecture of a computer system and its role in problem solving.
3. Discuss Python data types, variables, operators, and expressions with examples.
4. Explain Python’s input and output operations with suitable programs.
5. Write a Python program to perform basic arithmetic and demonstrate different operators.

UNIT II — CONTROL STRUCTURES & DATA SEQUENCES

🔹 2-Mark Questions
1. What is a Boolean expression?
2. What is the purpose of indentation in Python?
3. Write the syntax of an if statement.
4. What is a multi-way selection?
5. Differentiate between definite and indefinite loops.
6. What is a Boolean flag?
7. What is an infinite loop?
8. What is the difference between while and for loops?
9. What is a list in Python?
10. What is a string in Python?
11. What is a dictionary in Python?
12. What is a range object?
13. What is indexing and slicing in Python?
14. How are elements added to a list?
15. What is the use of break and continue statements?
🔹 5-Mark Questions
1. Explain the use of selection statements (if, if-else, if-elif-else) with examples.
2. Explain different looping structures in Python with examples.
3. Discuss the difference between definite and indefinite loops with examples.
4. Write short notes on Boolean expressions and flags.
5. Explain string manipulation operations in Python.
6. Explain the use of lists and their basic operations.
7. Explain the concept of ranges and how they are used in loops.

🔹 10-Mark Questions
1. Explain in detail the control structures in Python with suitable examples.
2. Discuss iteration and selection control structures in Python.
3. Explain string, list, and dictionary manipulations in Python with examples.
4. Write a Python program using loops and conditional statements to perform a specific task (like factorial,
prime number, etc.).
5. Explain ranges and their importance in iteration with examples.

UNIT III — FUNCTIONS & RECURSION

🔹 2-Mark Questions
1. What is a function?
2. What is the difference between a value-returning and a non-value-returning function?
3. What is the purpose of the return statement?
4. Define parameter and argument.
5. What are keyword arguments in Python?
6. What are default arguments?
7. What is variable scope?
8. Define recursion.
9. What is a recursive function?
10. Give one example of a recursive problem.
11. What is the purpose of function modularization?
12. What is a local variable?
13. What is a global variable?
14. Define parameter passing.
15. What is meant by calling a function?

🔹 5-Mark Questions
1. Explain the concept of defining and calling functions in Python.
2. Explain parameter passing techniques with examples.
3. Discuss keyword and default arguments in Python with examples.
4. Explain variable scope and lifetime with examples.
5. Explain recursive functions with examples.
6. Write a program to demonstrate recursion.

🔹 10-Mark Questions
1. Explain functions in Python — definition, invocation, parameters, and return values with examples.
2. Explain recursion in detail with examples and advantages.
3. Write a Python program using recursive function to find factorial or Fibonacci sequence.
4. Discuss variable scope and parameter passing mechanisms in detail.
5. Explain the types of arguments supported in Python with suitable examples.

UNIT IV — OBJECTS, MODULES & FILE HANDLING


🔹 2-Mark Questions
1. What is an object in Python?
2. What are software objects?
3. What is turtle graphics?
4. Name any two turtle graphics methods.
5. What is modular design?
6. What is a Python module?
7. What is the difference between a module and a package?
8. How do you import a module in Python?
9. What is the purpose of a text file?
10. What are file modes in Python?
11. What is exception handling?
12. What is the use of the try and except statements?
13. What is the use of the finally block?
14. What is an exception object?
15. What is top-down design?

🔹 5-Mark Questions
1. Explain the concept of modular design and its advantages.
2. Explain the turtle graphics module with an example.
3. Write short notes on Python modules and how they are imported.
4. Explain the process of opening, reading, and writing text files in Python.
5. Explain exception handling with try, except, and finally blocks.
6. Write a short program to handle division by zero exception.

🔹 10-Mark Questions
1. Explain the concept of modular design in Python and the use of modules.
2. Discuss file handling in Python with examples for reading and writing text files.
3. Explain exception handling in Python in detail with syntax and examples.
4. Explain turtle graphics and its attributes with examples.
5. Explain top-down design and modularity using examples.

UNIT V — DICTIONARIES, SETS & OOP IN PYTHON

🔹 2-Mark Questions
1. What is a dictionary in Python?
2. What are keys and values in a dictionary?
3. What is a set in Python?
4. How are sets different from lists?
5. What is encapsulation?
6. Define inheritance.
7. Define polymorphism.
8. What is the use of the super() function?
9. What is the purpose of the __init__ method?
10. What are Python packages?
11. What is NumPy used for?
12. What is pandas used for?
13. What is matplotlib used for?
14. What is the difference between a module and a package?
15. What is method overriding?

🔹 5-Mark Questions
1. Explain the dictionary data type in Python with examples.
2. Explain set operations (union, intersection, difference) with examples.
3. Explain the concept of encapsulation in OOP.
4. Explain inheritance with an example.
5. Explain polymorphism in Python.
6. Write short notes on NumPy, pandas, and matplotlib packages.

🔹 10-Mark Questions
1. Explain Object-Oriented Programming in Python — encapsulation, inheritance, and polymorphism with
examples.
2. Explain dictionary and set data types in detail with operations and examples.
3. Explain Python packages and their applications with examples of matplotlib, NumPy, and pandas.
4. Write programs using NumPy arrays and matplotlib for data visualization.
5. Explain method overriding and multiple inheritance with examples.

Common questions

Powered by AI

The essential components of a computer system architecture include the Central Processing Unit (CPU), memory (both RAM and storage), input/output devices, and the system bus. The CPU executes instructions and processes data, thereby performing computations essential for problem solving. Memory stores both the data being processed and the instructions for processing, allowing for quick access and modification. Input/output devices enable interaction with the system, allowing for data entry and result retrieval, which is crucial for problem validation and application in real-world scenarios. The system bus facilitates communication between all components, ensuring coordinated operation throughout the computational task .

Python packages like NumPy, pandas, and matplotlib significantly enhance scientific computing and data visualization by providing tools for efficient data manipulation and representation. NumPy offers fast array computations, allowing for operations on entire arrays/matrices, which is critical for numerical analysis and large-scale data processing. pandas provide powerful data structures for managing and analyzing data with support for complex operations on datasets, including data cleaning and manipulation. matplotlib enables the creation of a diverse array of plots and graphs, facilitating the visualization of data patterns and insights. Together, these ensure that Python remains a key tool in data-driven fields .

In Python's OOP, encapsulation restricts access to object components, safeguarding data through private and public access, which enhances data integrity and security. Inheritance allows new classes to inherit properties and methods of existing classes, promoting code reuse and hierarchy structure, such as creating a 'Vehicle' class and deriving 'Car' and 'Truck' classes with specific attributes. Polymorphism allows different classes to be treated as instances of the same class through a common interface, enabling method overriding and enhancing flexibility in function behavior, as illustrated by different 'Shape' classes calculating the area in different ways while being accessed uniformly. These OOP principles enhance modularity, scalability, and maintainability of Python applications .

Functions in Python encapsulate code into reusable blocks, improving program organization and readability by keeping related operations together while reducing redundancy. Recursion, a function calling itself, provides elegant solutions to complex problems like computing factorials or traversing data structures such as trees. It simplifies code that must perform the same task on smaller data sets, reducing code length and potential errors. Recursion, although potentially less efficient due to overhead from repeated function calls and stack usage, enables intuitive implementation of algorithms that are inherently recursive, thus balancing complexity with human readability .

Control structures in Python, including selection (if, if-else, if-elif-else) and iteration (for, while loops), allow for the development of programs that can make decisions and repeat operations. Selection structures enable conditional operations based on Boolean expressions, facilitating decision making. For instance, using if-else allows a program to execute different code blocks based on user input or computed conditions. Iteration structures enable repetitive task execution, managing lists or ranges dynamically. For example, a for loop can iterate over a list of items, and a while loop can execute until a certain condition is met, thereby enhancing program efficiency and reliability .

Exception handling in Python improves program robustness by managing runtime errors and allowing a program to continue execution or fail gracefully. The try block contains code that might cause exceptions, while except blocks handle specific errors, providing corrective actions or fallbacks without crashing the program. The finally block executes code, such as closing resources, regardless of exceptions, ensuring that cleanup operations occur. For example, handling division by zero using try-except prevents application crashes by checking for exceptions and providing user-friendly error messages, thereby enhancing user experience and program reliability .

Modular design and Python modules enhance software development by promoting separation of concerns, allowing developers to break down programs into manageable, independent components. This leads to improved code readability, maintenance, and reusability. Modules allow encapsulation of functionalities, process hiding, and reuse across different parts of an application or even across different projects. By importing modules as needed, developers can build upon existing functionalities, test components independently, and update them without affecting unrelated parts of the program, thus improving development efficiency and minimizing errors .

Python's dynamic typing allows variables to change types at runtime, enhancing flexibility as developers can use variables without explicitly declaring their type. For example, a variable can be an integer in one operation and a string in another. Type conversion, using functions like int(), float(), and str(), allows explicit conversion between types, enhancing usability when operations require specific data types. For instance, an integer can be converted to a string using str() for concatenation purposes .

Python handles file operations through open(), read(), write(), and close() functions, allowing applications to interact with the file system. Files can be opened in different modes, such as read ('r'), write ('w'), and append ('a'), enabling flexibility in data management. This supports systematic data storage, retrieval, and modification, which is essential for applications requiring persistent storage. Reading and writing text files facilitates data import/export operations, crucial for data exchange and logging mechanisms. The context manager with the 'with' statement enhances error handling and resource management by ensuring proper file closure post operations, thus preventing resource leaks .

Dictionaries in Python provide an efficient means of managing key-value data pairs, allowing for fast retrieval, addition, and deletion of entries based on keys, enhancing performance in lookup operations compared to lists. They excel in scenarios requiring associative arrays or when data needs to be accessed via identifiers. Sets, meanwhile, offer unique data storage and are optimized for membership testing, leveraging hash tables for O(1) average time complexity on operations like checking for presence, adding, or removing elements. They are particularly beneficial for operations involving mathematical set theory, such as unions, intersections, and differences, thus providing tools for efficient data handling .

You might also like