Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Python Question Bank

The document is a question bank for a course on Problem Solving Using Python, covering various topics across five modules. It includes questions on algorithms, flowcharts, Python programming concepts, file operations, and object-oriented programming. Each module contains multiple questions that require the application of Python programming skills to solve problems or explain concepts.

Uploaded by

eshauppin1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Question Bank

The document is a question bank for a course on Problem Solving Using Python, covering various topics across five modules. It includes questions on algorithms, flowcharts, Python programming concepts, file operations, and object-oriented programming. Each module contains multiple questions that require the application of Python programming skills to solve problems or explain concepts.

Uploaded by

eshauppin1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PROBLEM SOLVING USING PYTHON - 4CSPL1011

QUESTION BANK

MODULE 1
1 Define algorithm and explain building blocks of algorithm.Write an algorithm to find maximum value in a list
2 With neat sketch explain the following building blocks of algorithm: (i) Statements (ii) Control flow
3 (i)What is an algorithm? List the characteristics of a good algorithm. (ii)Write an algorithm to find the square root of a
number.
4 Identify simple strategies for developing an algorithm.
5 Write an algorithm that calculates the salary of an employee. Prompt the user to enter the Basic salary, HRA, TA and DA.
Add these components to calculate the Gross salary.
6 Write an algorithm for the following: (i). Calculating area and circumference of a circle. (ii). Check if a given year is a
leap year or not.
(i) Write an algorithm to find the minimum in a list.
(ii) Write an algorithm to insert a card in a list of sorted cards.
7 Explain Towers of Hanoi. Write the Pseudocode for Towers of Hanoi.
8 Outline the Towers of Hanoi problem. Suggest a solution to the Towers of Hanoi problem with relevant
Diagrams.
9 (i)Summarize the advantages and disadvantages of flowchart. (ii) Summarize the symbols used in flowchart.
10 (i) Develop a flowchart to check whether the given number is a prime number or not. (ii) Develop a pseudocode to
perform arithmetic operations.
11 (i) What is flowchart? List down symbols and rules for writing flowchart.
(ii) Draw a flowchart to count and print from 1 to 10.

12 Define iteration and recursion. Write an algorithm to find the factorial of a number using iteration and recursion.
13 What is function ? Write a program to display largest of three numbers using function.
14 i) Write an algorithm to find the greatest common divisor (GCD) of two numbers using Euclid's algorithm.
ii) Design an algorithm that calculates the Fibonacci sequence up to a given term using recursion.

15 Design a Flowchart,Algorithm,Pseudocode for calculating the factorial of a number using a loop.


16 Using pseudocode, outline the steps to insert a new card into a sorted list of cards while preserving the sorted order.

17 Analyze the iterative solution for the Towers of Hanoi problem. Explain how iteration is applied to solve the problem and
compare its efficiency with the recursive approach. Discuss any trade-offs between the two solutions.

18 Write an algorithm and design a flowchart to check whether a given number is a perfect number or not.
19 Write a python program find factorial of a given number using recursion function.
20 i) Describe the process of recursion and provide an example of calculating the power of a number using recursion.
ii) Define iteration and explain with an example how iteration is used to find the sum of first N natural numbers.

MODULE 2
21 List the types of operators in python and thus explain the different expressions involved in python.
22 Explain with an example, break statement and continue statement using while loop in Python.
23 Explain the looping statements (while and for loops) with an example.
24 (i) Write a python program to find the greatest among three numbers.
(ii) Write a python code to print all numbers in a range (a,b).
25 (i). Write a python program to find the greatest among three numbers.
(ii) Write a Python program to find the sum of N natural numbers.
26 List the different types of conditional control statements and explain them with suitable examples.
27 (i). Write a python program to implement a student mark system using chained conditional if control structure. (ii). Write
a python program to find the given number is positive, negative or zero using Nested if conditional control structure.
28 Explain any ten methods in a string with examples.
29 (i) Create a Python program to determine whether a string is a palindrome or not.
(ii) Write a Python program to count the number of vowels in a string provided by the user.
30 Explain the different types of operators in Python (arithmetic, relational, logical, bitwise, assignment, and membership
operators) with suitable examples. Discuss their uses in Python programming.
31 Discuss the working of the continue statement and the break statement in the for loop with suitable examples. What
happens when they are used in a loop, and how do they alter the flow of control?
32 (i) Write a Python program to check whether a given year is a leap year or not using the if conditional control structure.
(ii) Write a Python program to check whether a number is prime or not using control statements.
33 Write a Python program that uses multiple if-elif-else statements to check if a given number is divisible by 2, 3, and 5.
The program should print the appropriate message for each condition.
34 (i) Write a Python program to reverse a given string.
(ii) Write a Python program to find the frequency of each character in a string.
35 Explain the use of join(), split(), strip(), replace(), lower(), and upper() methods in Python strings with examples. Discuss
when to use each of these methods in real-life scenarios.
36 Write a Python program that finds sum all the numbers in a list until it encounters a negative number, using a for loop. If a
negative number is encountered, the loop should terminate using the break statement.
37 i) Write a Python program to find the square root of a number by Iterative Newton’s method.
ii) Write a Python program to find simple interest..
38 i) Write a Python program to calculate the sum of all even and odd numbers separately for a given list of integers.
ii) Write a Python program to check a number is positive, negetive or zero.

39 i) Write a Python program to to create and display elements of list and tuple.
ii) Write a Python program to check whether the number is odd or even.

40 Explain the concept of recursion in Python. How does a recursive function work? Provide an example of a recursive
function and explain its execution.
41 (i) What is a Python Tuple? What are the advantages of Tuple over list? (ii)“Tuples are immutable”. Explain with an
example.
42 What is tuple in python? Analyze how it differs from the list?
43 Illustrate the ways of creating the Tuple and the Tuple assignment with suitable programs.
44 (i). Explain the basic Tuple operations with examples. (ii). Write a Python program to check whether an element ‘y’ and
‘a’ belongs to the tuple mytuple = (‘p’,’y’,’t’,’h’,’o’,n’).
45 (i) Write a Python program to delete all the duplicate elements in a list.
(ii) Write a Python program to sort ‘n’ numbers in a list using insertion sort.
46 (i) Write a Python program to sort ‘n’ numbers in a list using selection sort.
(ii) Write a Python program to perform linear search.
47 Demonstrate the working of +,* and slice operators in python lists and tuples.
48 (i) Write the Python code to find the minimum among the list of 10 numbers.
(ii) Demonstrate with simple code to draw the histogram in Python.
49 Describe the set and explain its operations with suitable examples.
50 Describe different functions associated with sets with suitable examples.
51 Explain in detail about dictionaries and its operations with suitable examples.
52 (i) Using a dictionary variable, Write a Python code to estimate the frequency of each character in a sentence obtained
from the user.
(ii) Write the Python code to remove multiple keys in a dictionary using del.
53 What is a function? How is a function defined and called in Python? Explain with a simple program.
54 List the different types of arguments / parameters used in function with suitable examples.
55 Using recursion (i) Write a Python program to find the GCD of two numbers. (ii)Write a Python program to find the
exponent of a number.
56 Describe the following (i) Creating the list (ii) Accessing values in the lists (iii) Updating the list (iv) Deleting the list
elements
57 (i) Write a Python code using a function to generate the first ‘N’ Fibonacci series numbers.
(ii) Write a Python program to find the factorial of the given number using recursion.
58 Define Exception and Describe the use of try-except-finally block in python with syntax and sample program.

59 (i) Write a program to catch a divide by zero exception. Add a finally block too.
(ii) Write a Python program to handle multiple exceptions.
60 Mention the Python list methods with examples. Why is it necessary to have both the functions append( ) and extend( )?

MODULE 4
61 What are modules in python? How will you import them? Explain the concept by creating and
importing a module using a simple program.
62 Explain the following: (i). Predefined Modules (ii). User defined Modules.
63 Discuss the different modes for opening and closing a file.
64 Tabulate the different modes for opening and closing a file and briefly explain the same.
65 Explain the methods used to read and write into a file with examples.
66 (i) Write a Python code to copy the contents of one file to another.
(ii) Write a Python code to count the number of words in a file.
67 (i) Write a Python code to read and print the first 20 characters in a file.
(ii) Explain seek() and tell() method used in file operation.
68 Explain the role of Tkinter in Python GUI programming. Discuss its features and advantages.

69 Provide examples of Tkinter applications such as a simple calculator, text editor, or image viewer.

70 Provide examples of using the seek() method to move the file pointer to different positions within a file
71 Write a python program to display the calendar of the year, & month of the year.
71 Explain the concept of modules and packages in Python. Discuss their importance in organizing and structuring Python
code.
72 Explain the significance of the math module in Python. Discuss the mathematical functions and constants available in this
module
73 Discuss the importance of date and time functions in Python. Explain how dates and times are represented and
manipulated using built-in functions and modules.
74 Describe the process of importing modules and packages in Python. Discuss different methods of importing and their
advantages/disadvantages.

75 Writea python program to find minimum and maximum in the list using user defined functions.

76 Write a python program for basic calculator operations


77 Write a python program to i) add new content to the file and display the file content on screen.
ii) add additional content to file and display the file content on screen.
78 Describe various file operations with examples.
79 Explain general syntax for creating files with various permissions.
80 What python packages and explain with examples.

MODULE 5
81 Define a class Person in Python with attributes for name and age. Write a method to display the name and age for two
persons.
82 (i) What is a class and object in Python? Define it with an example.
(ii) What is the constructor in Python? Explain the purpose of the init method in Python.
83 Define and explain the difference between instance methods, class methods, and static methods in Python. Provide suitable
examples.
84 How can access specifiers (public, private, protected) be implemented in Python? Discuss their importance with examples.

85 Explain the significance of the init method in Python. Illustrate with a program that initializes a Student object with
name and marks.
86 Write a Python program to create a Person class with name and age as instance variables. Implement methods to display and
update the age.
87 Implement a Bank account system using OOPS concepts in Python.Create Bank class with attributes-Account_number,
Account_holder, Account_balance and methods-deposit(), withdraw(), get_account().
88 How can access specifiers (public, private, protected) be implemented in Python? Discuss their importance with examples.

89 Write a class with following criteria


Class name: Flower
Objects: lilly, rose, hibiscus
Properties: price,color,smell
Methods: get(), display()

90 Write a Python program to create a class named ROOM with dimensions as attributes. Then create two objects for the
class named ROOM, calculate and print the area for study and dining room.
91 Illustrate a program to create a class named Dog with name and color as attributes demonstrating init() method.
92 Explain how to create multiple objects to the class with programming examples.
93 Explain the Features of Object Oriented Programming in Python.
94 What is a static method and how is it different from a class method? What is the purpose of the self keyword in
methods?
95 Write a python program to display information about employees in the organization using class.
96 Write a Python program to create a person class. Include attributes like name, country and date of birth. Implement a
method to determine the person's age.
97 Write a Python program to create a calculator class. Include methods for basic arithmetic operations.
98 Explain how you get access to the data members and member functions of the class with a sample program.
99 Write a python program to display student information using class.
100 Write a Python program to create a class representing a Circle. Include methods to calculate its area and circumference.

You might also like