Python Prog Question Bank 1 to 5 Units 2425
Python Prog Question Bank 1 to 5 Units 2425
1. What are the basic numeric data types in Python? Give an example of each.
2. How do you declare and use a Boolean variable in Python?
3. Write a short code snippet to demonstrate how to convert a float to an integer.
4. What is the difference between int and float data types in Python?
5. What is the syntax for taking input from the user in Python? Provide an example.
6. Explain the use of the break statement in a while loop with an example.
7. How does the continue statement affect loop execution?
8. What is the purpose of the else block in Python loops?
9. Write a Python expression that concatenates two strings.
10. What does the pass statement do, and where might it be used?
1. Explain the concept of data types in Python. Describe and provide examples for int,
float, bool, and complex.
2. Discuss string data types in Python. Explain at least three string operations with
code examples.
3. How do you take input and display output in Python using standard input (input)
and output (print) functions? Provide examples.
4. What is type conversion in Python? Explain the difference between implicit and
explicit type conversion with examples.
5. Write a program that demonstrates the use of conditional statements (if, elif, and
else) to determine if a number is positive, negative, or zero.
6. Explain the difference between a for loop and a while loop in Python. Provide
examples to show when each should be used.
7. Discuss how the break and continue statements can be used to manipulate loop
flow. Provide an example program.
8. What is the purpose of the else block in loops? Explain with an example of a for
loop that uses it.
9. Write a Python program that reads a number from the user and calculates the
factorial using a while loop.
10. Discuss the significance of the pass statement in Python. Explain its practical use
cases with an example program.
Unit 2:
1. Explain how to create a function in Python, including parameters and return values.
Provide an example program.
2. Discuss the concept of recursive functions. Write a Python program to calculate the
factorial of a number using recursion.
3. What are lambda functions? How are they different from regular functions?
Provide two examples to demonstrate their use.
4. Write a program to demonstrate list operations, including adding, replacing,
removing elements, and sorting a list.
5. Explain tuples in Python. Compare them with lists, highlighting their immutability.
Provide examples where using a tuple is preferable to a list.
These questions ensure comprehensive coverage of function concepts and data structures while
encouraging both theoretical understanding and practical implementation.
Unit 3:
These questions address key concepts of dictionaries, sets, and strings while also introducing
foundational Object-Oriented Programming concepts with practical applications.
Unit 4:
1. Explain the steps to connect Python with a MySQL database. Write a program to
create a database connection and a table.
2. Write a Python program that performs basic CRUD (Create, Read, Update, Delete)
operations on a MySQL database.
3. Discuss DDL and DML operations with detailed examples in Python. Write a
program to create a table (DDL) and insert data into it (DML).
4. What is transaction handling in databases? Write a Python program to demonstrate
a transaction with commit and rollback operations.
5. Explain how database errors can be handled in Python. Write a program that
catches and handles an error during a database operation.
These questions ensure a blend of theoretical understanding and practical skills for working with
databases in Python.
Unit 5 :
These questions provide a balanced mix of conceptual and practical learning opportunities for
NumPy and Pandas in Python data analysis.