[go: up one dir, main page]

0% found this document useful (0 votes)
54 views10 pages

Unit-wise Important Question Bank - Python Bcc402

The document is a comprehensive question bank for a Python programming course, organized by units covering various topics such as operators, data structures, loops, file handling, and libraries like NumPy and Pandas. Each unit contains multiple questions that require explanations, code examples, and demonstrations of Python concepts. It serves as a study guide for students to prepare for exams or enhance their understanding of Python programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views10 pages

Unit-wise Important Question Bank - Python Bcc402

The document is a comprehensive question bank for a Python programming course, organized by units covering various topics such as operators, data structures, loops, file handling, and libraries like NumPy and Pandas. Each unit contains multiple questions that require explanations, code examples, and demonstrations of Python concepts. It serves as a study guide for students to prepare for exams or enhance their understanding of Python programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

UNIT-WISE IMPORTANT QUESTION BANK

PYTHON BCC402

UNIT 1
1. Differentiate between / and // operator with an example.

2. Illustrate unpacking tuples, mutable sequences, and string concatenation with


examples.

3. Define operators in Python.

4. Write a basic Python code to add 2 numbers.

5. Explain any five features of Python.

6. Describe the concept of list slicing with a suitable example.

7. Show the way to import a module in Python.

8. Define floor division with an example.

9. Explain the difference between append and extend in Python.

10. Differentiate between Python arrays and lists.

11. What is a dictionary in Python?

12. What is object-oriented programming (OOP) in Python? Give an example.

13. What will be the output of:

def count1(s):

vowels = "AEIOUaeiou"

count = 0

14. What will be the output of:

list1 = ['M', 'o', 'n', 'k', 'y']

print("@".join(list1))

15. Describe Tuple in Python.

16. What is the significance of dynamic typing in Python? Write a Python program to
demonstrate dynamic typing using variable reassignment of different data types.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


17. Explain the difference between is and == operators in Python. Write a Python program
to compare two lists using both operators and show the output.

18. Write a Python program to convert a given character into its ASCII value and vice
versa.

19. Explain how 'else' clause can be used with 'for' loop in Python. Write a Python
program to check if a number is prime using 'for-else'.

20. Write a Python program to remove all falsy values (0, None, False, [], '', etc.) from a list
using the filter() function. Show the output for the list: [1, 0, 0, 2, 'hi', ' ', []].

21. Explain 'split()' and 'join()' string functions with proper examples. Write a Python
program that converts a comma-separated string to a list and vice versa.

22. Write a Python program to demonstrate mutable and immutable types by modifying
a list and showing the error when trying to modify a tuple.

23. Write a Python code to demonstrate variable scope in Python. Explain with an
example showing the difference between global and local variables.

24. Explain the concept of Python blocks (Indentation) with an example. What error does
Python throw if indentation is not proper? Write a program showing the error.

25. Write a Python program to check the type of various data types (int, float, complex,
str, bool) using the type() function and print their types dynamically.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


UNIT 2

1. Explore the working of while and for loops with examples.

2. Describe the behavior of range(start, stop) in Python.

3. Explain the role of precedence with an example.

4. Demonstrate five different built-in functions used in string operations. Write a program to check
whether a string is a palindrome.

5. Explain for and while loops with flow diagrams and examples.

6. Explain continue, break, and pass statements with examples.

7. Develop a program to calculate the reverse of an entered number.

8. Write the structure of if-else statements in Python.

9. Describe recursion. Write a program to generate the Fibonacci series.

10. Write a Python program using a for loop to print the multiplication table of a number entered
by the user.

11. Develop a Python program that prints all prime numbers between 1 and 100 using for and else
clauses.

12. Write a Python program that calculates the factorial of a number using both while loop and for
loop separately.

13. Write a Python program to check if the given string is a palindrome using while loop (without
slicing or reverse methods).

14. Explain how the pass statement works inside loops. Write a Python code where the pass
statement is used inside an empty if block within a for loop.

15. Write a Python program using nested for loops to print the following pattern:

2 2

3 3 3

4 4 4 4

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


16. Develop a Python program to find the sum of all odd numbers between 1 to N using a while
loop.

17. Explain the difference between while and do-while loop constructs. Write a Python equivalent
to simulate a do-while loop to accept numbers until a positive number is entered.

18. Write a Python program to demonstrate the use of nested if-else for determining the largest of
three numbers.

19. Write a Python program to count the number of vowels and consonants in a given string using
a for loop and if-else conditions.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


UNIT 3
1. Describe the differences between linear search and binary search.

2. Show an example where both Keyword arguments and Default arguments are used
for the same function.

3. Write a Python program triangle(N) that prints a right triangle pattern using *.

4. Explain the lambda function.

5. Discuss different types of argument-passing methods in Python. Explain variable-


length arguments with an example.

6. Describe the while loop in Python.

7. Differentiate between global and local variables.

8. Write a recursive Python program to compute the factorial of a number.

9. What is a List? Explain with an example.

10. Write a Python program to check if a 3-digit number is an Armstrong number.

11. Write a Python program to remove all duplicates from a list without using set(). Print
the original and the modified list.

12. Explain how to create a Dictionary in Python. Write a program to count the frequency
of each character in a given string using a dictionary.

13. Write a Python function that accepts a list of numbers and returns both the maximum
and minimum values (without using built-in functions like max() or min()).

14. What is list comprehension? Write a Python program to create a list of squares of even
numbers from 1 to 20 using list comprehension.

15. Explain the difference between mutable and immutable data types in Python with
suitable examples for each.

16. Write a Python program to merge two dictionaries into one. Demonstrate with an
example.

17. Develop a Python function to accept a tuple of numbers and return a new tuple
containing only the even numbers.

18. Explain the concept of a Python set. Write a program to perform union, intersection,
and difference operations on two sets.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


19. What is a lambda function in Python? Write a Python program to filter out all numbers
greater than 10 from a list using lambda and filter().

20. Create a Python function that accepts any number of positional arguments and returns
their sum. Demonstrate by calling the function with 3, 5, 10, and 15 as arguments.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


UNIT 4
1. Write a Python program to read the last n lines of a file.

2. How to use functions defined in library.py inside main.py? Explain.

3. Find the largest word present in a file using Python file handling.

4. Construct a program to change the contents of a file by separating each character by a


comma.

5. Explain the use of the with construct in Python with an example.

6. How to create a Python file that can be imported as a library as well as run as a
standalone script?

7. Describe the difference between import library and from library import * in Python.

8. Explain the importance of Exception Handling. Explain try-except-finally block with


an example.

9. Explain File Input and Output operations.

10. Write a Python program to open a text file in write mode, write multiple lines of data
into it, and then read the contents of the file.

11. Explain the difference between the file modes 'r', 'w', 'a', and 'r+' with suitable
examples for each.

12. Write a Python program to count the total number of words, characters, and lines in a
file named data.txt.

13. Explain the seek() and tell() functions in Python file handling with proper examples.

14. Write a Python program that reads a file and prints each line after stripping the
newline (\n) character.

15. Explain how exception handling is used during file operations in Python. Write a
program that handles the error when a file does not exist.

16. Write a Python program to copy contents of one file into another file.

17. What is the significance of using the with statement for file handling in Python?
Explain with an example where a file is read using this method.

18. Write a Python program to read a CSV file and display its contents line by line.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


19. Differentiate between text files and binary files in Python. Provide code examples to
write and read data in both formats.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


UNIT 5
1. Describe the difference between linspace and arange in NumPy.

2. Describe different functions of Matplotlib and Pandas.

3. Write a Python GUI program to create a label and change its font style using Tkinter.

4. Calculate the sum of the diagonal elements of a NumPy array.

5. Write a Python program to create a 3x3 identity matrix using NumPy.

6. Explain the difference between a NumPy array and a Python list with suitable examples.

7. Write a Python program to generate an array of 10 random integers between 5 and 50


using NumPy.

8. Describe the reshape() function in NumPy. Write a Python code to convert a 1D array
to a 2D array using reshape().

9. Write a Python program using NumPy to perform element-wise addition, subtraction,


multiplication, and division of two arrays.

10. Explain the concept of DataFrame in Pandas. Write a Python program to create a
DataFrame from a dictionary and display it.

11. Write a Python program to read a CSV file into a Pandas DataFrame and display the
first 5 rows using head().

12. Differentiate between Series and DataFrame in Pandas with examples.

13. Write a Python program to filter rows in a Pandas DataFrame where a column value is
greater than a specified number.

14. Explain the use of groupby() function in Pandas with an example.

15. Write a Python program to plot a bar chart using Matplotlib with sample data.

16. Explain the role of labels, title, and legend in a Matplotlib plot with an example plot.

17. Write a Python program to plot a pie chart using Matplotlib showing the percentage
distribution of marks in five subjects.

18. Write a Python GUI application using Tkinter to create a simple calculator that
performs addition and subtraction.

19. List and explain any five commonly used Tkinter widgets with examples of their usage.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK


20. Write a Python program using Tkinter to create a simple login form with fields for
Username and Password along with a "Submit" button. On clicking the button, display
the entered values using a label.

PYTHON PROGRAMMING BCC402 | POSSIBLE IMPORTANT QUESTION BANK

You might also like