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

Python Prog Question Bank 1 to 5 Units 2425

Uploaded by

faisaldabos
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
18 views4 pages

Python Prog Question Bank 1 to 5 Units 2425

Uploaded by

faisaldabos
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Unit:1

Short Type Questions (2–3 sentence answers):

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?

Essay Type Questions (5–10 sentences with examples):

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:

Short Type Questions (2–3 sentence answers):

1. What is the difference between positional and keyword arguments in Python


functions?
2. Explain the concept of default parameter values with an example.
3. What is the purpose of using the global keyword in Python? Provide a use case.
4. Write a lambda function to calculate the square of a number.
5. What is the difference between a list and a tuple in Python?

Long Type Questions (5–10 sentences with examples):

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:

Short Type Questions (2–3 sentence answers):

1. How do you add a new key-value pair to a dictionary in Python? Provide an


example.
2. What is the difference between accessing a value in a dictionary and replacing it?
3. Write a Python statement to traverse a dictionary and print all keys.
4. What is the purpose of inheritance in Object-Oriented Programming?
5. Explain the concept of polymorphism with a simple example in Python.

Long Type Questions (5–10 sentences with examples):


1. Discuss the basic operations on dictionaries in Python, including adding, removing
keys, and accessing values. Provide a program to demonstrate these operations.
2. Write a Python program that demonstrates set operations such as union,
intersection, difference, and checking membership.
3. Explain the concept of classes and objects in Python. Write a program to define a
class with attributes and methods, and create multiple objects from it.
4. Discuss the concept of inheritance in Python with examples. Show how child classes
can override methods of the parent class.
5. What is exception handling in Python? Explain with an example that demonstrates
the use of try, except, and finally.

These questions address key concepts of dictionaries, sets, and strings while also introducing
foundational Object-Oriented Programming concepts with practical applications.

Unit 4:

Short Type Questions (2–3 sentence answers):

1. How do you establish a connection to a MySQL database in Python? Provide the


necessary code snippet.
2. What is the difference between DML and DDL operations in a database? Give an
example of each.
3. Write a Python statement to execute a SQL INSERT operation using a database
cursor.
4. What is a database transaction? Why is it important?
5. How can you handle database errors in Python? Mention one key method or class
for error handling.

Long Type Questions (5–10 sentences with examples):

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 :

Short Type Questions (2–3 sentence answers):

1. What is NumPy, and why is it important for data analysis in Python?


2. How do you create a NumPy array from a Python list? Provide an example.
3. What is a Pandas Series? How is it different from a NumPy array?
4. What is the purpose of the drop() method in Pandas? Write an example.
5. Explain what happens when missing data is encountered in a Pandas DataFrame.
How can it be handled?

Long Type Questions (5–10 sentences with examples):

1. Discuss the core functionalities of NumPy. Write a Python program to demonstrate


array creation, indexing, and transposition.
2. Explain Universal Array Functions in NumPy with examples. Demonstrate at least
two functions, such as np.sqrt and np.mean.
3. What is a Pandas DataFrame? Write a program to create a DataFrame, reindex it,
and drop an entry.
4. Explain the process of data alignment in Pandas with an example program. Include
how Pandas aligns indices during operations.
5. What is the significance of handling missing data in Pandas? Write a program to
detect, fill, and drop missing values in a DataFrame.

These questions provide a balanced mix of conceptual and practical learning opportunities for
NumPy and Pandas in Python data analysis.

You might also like