0% found this document useful (0 votes)
24 views5 pages

Question Bank Python

The document outlines a comprehensive set of programming exercises and explanations related to Python, covering topics such as arithmetic operations, control structures, data types (lists, dictionaries), file handling, exception handling, and object-oriented programming. Each module contains specific tasks, including writing programs, explaining concepts, and demonstrating various Python functionalities. The exercises are designed to enhance understanding and practical skills in Python programming.

Uploaded by

manumanu63607
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)
24 views5 pages

Question Bank Python

The document outlines a comprehensive set of programming exercises and explanations related to Python, covering topics such as arithmetic operations, control structures, data types (lists, dictionaries), file handling, exception handling, and object-oriented programming. Each module contains specific tasks, including writing programs, explaining concepts, and demonstrating various Python functionalities. The exercises are designed to enhance understanding and practical skills in Python programming.

Uploaded by

manumanu63607
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/ 5

Module 1

1. Write a python program to read two integer values and display the result of all
arithmetic operation.
2. Explain single line and multi line comments in python with suitable example.

4 Explain the comparison operators in python with the help of suitable example.
5. Write a python program to display the name and age as follow:
Sample Output:
Good Morning
Enter your name:pqr
Enter your age:25
Hi pqr next year you will be 26
6 Write a python program to check whether the person is eligible to vote or not
Sample Output:
Test Case 1
Enter your age:18
You are eligible to vote
Enter your age:16
You are not eligible to vote

7 Explain the concept of if -else construct in python


Write a program that take balance amount from a user if the balance is less
than 1000 print “Balance is low” otherwise print “sufficient balance”.
Enter the balance:800
Balance is low
Enter the balance:1500
Sufficient Balance
8 Demonstrate the concept of if-elif ladder
Write a program that reads the cgpa as input from the user and prints the
corresponding grade based on following scale:
CGPA>9.5=Grade S
9.0 To 9.5=Grade A
8.0 to 8.5=Grade B
7.0 to 7.9=Grade C
6.0 to 6.9=Grade D
5.0 To 5.9=Grade E
<5.0=Fail

9. Write a python program to print even numbers using for loop


10 Write a python program to accept the character from the user and check the
following:
i) If the entered character is alphabet check whether character is vowel
or not
ii) If the entered character is digit print wrong input
iii) If the entered character is -1 terminate the program.
11. Write a python program to print factorial of a number using loops.
12 What are modules in python?Explain random module in python
13. Demonstrate the different type of functions available in python .
Write a program to take two integer values a,b and define function sum() and
division() and return the result.
14. Compare the local and global variables and give one suitable example
15 Explain the concept of exception handling in python

16 Given two integers num1 and num2 perform division in try block. If the division
by zero error occurs print “division by zero is not allowed”
Module 2
1 Explain the concept of list in python by listing out its properties which
distinguish it from tuples.
2 Explain the following list methods with suitable example:
i) append()
ii) extend()
iii) insert()
3 Explain the inbuilt method random.choice() and random.shuffle() performed on
list
4 Write a python program to find the maximum of first and last element in the
list
5 Write a python program to find the sum of list elements
6 Write a python program to demonstrate the working of sort(),reverse()
methods
7. Create a list and count the occurrence of specified element in the list
Sample Output:
[10,20,30,10,20]
Enter Element:10
10 occurs 2 times

8. Explain the 3 ways of creating dictionaries with example for each method
9. Explain the following dictionary methods with examples:
i) .keys()
ii) .values()
iii) .items()
iv) .get()

10. Write a python program to count the number of occurrence of Each character
in a string as a key value pair in dictionary.
11 Write a python program to create a list having multiples of 7
Sample Output:
[7,14,21,28,35,42,49,56,63,70]
12 Create a list of integers and find the sum without using inbuilt function
13 Write a python program to create dictionary using lists
14 Write a python program that asks the user to enter name then:
i) Print the name in Uppercase and lowercase
ii) Print the name in titlecase
Sample TestCase:
Enter Name: Pooja
Uppercase: POOJA
Lowercase: pooja

15 Write a python program to create a dictionary having the numbers in


range(1,6) and its square as a value.
Sample Output:
{1:1,2:4,3:9,4:16,5:25)
16 Explain the following list methods:
Pop(),del, clear()

Module 3
1. List and explain the escape characters used in Python programming
2. What is the purpose of use of raw string.Write a program to obtain the
following output :
That is Carol\’s cat\n I like it
It always\’s grabs the thing\\s

3. Explain the following string methods with suitable example.


i) Upper()
ii) Lower()
iii) Isupper()
iv) Islower()
4. Explain the concept of in and not in operators in string
Write a python program to count how many times “is” appears in “This is a
simple string,is it not?”
5. Write a python program to repeatedly ask the age and password from the user
until they provide valid input as shown in the sample test case:

6. Explain the following string methods with suitable example:


i) Isalpha()
ii) Isdecimal()
iii) Isalnum()
iv) Isspace()
v) Istitle()

7. Explain the following os method with example:


i) Os.getcwd()
ii) Os.makedir()
iii) Os.chdir()
8. Explain the three ways of creating/setting the path in files.
9. Write a python program to explain read ,write and append mode in python files
10. Explain the various modes used in python files.
11. Wpp to get the following from any file path
i) basename
ii) dirname
iii) filesize
12. Explain the different parts of the path with suitable example.or
Explain the following path part with suitable example:
anchor,stem,suffix,name,parent
13. Write a python program that takes string from the user and count the number
of vowels in a string.
Sample output:
Enter a string:
Tech hub
Total Vowels:2
Module 4
1. Write a program demonstrating copying the file to another folder using shutil
module

2. Consider the given path:


C:\JP files1\mainfolder1\sf3\w1.docx
i) write a program demonstrating permanently deleting the file
ii) write a program to delete the path using rmtree()
3. Consider the given path:
C:\JP files1\mainfolder1\sf1
i) write a program to print all the available text files in a given folder
path.
ii) Write a program to delete all the text files available in a given folder.

4. WAPP to print the current folder and its corresponding subfolder and files.
Repeat the same task by considering the subsequent to be your current folder
5. WAPP to print all the folders,Subfolders and its files in a ZipFile
6. WAPP to find the size of file and size of compressed file
7. WAPP to extract all the subfolders and its files into current working directory
8. Write a program to print a box using single character with given width and
height.print suitable statements when its not a single character or if width and
height is less than 2.
9. Explain the different logging levels in python.
10 Define Assertions. Demonstrate an example of using assertions in a traffic light
simulation.
11 Explain the functions of the following buttons in Debug control window:
i) Go
ii) Step
iii) Over
iv) Out
v) Quit
12. Demonstrate the use of breakpoints in IDLE’S debugger using suitable program
13. Explain the working of logging.basicConfig() with suitable example.
14. Explain the concept of raising an exception with suitable example
Module 5
1. Explain the concept of classes and objects used in python

2. Write a definition for a class named Rectangle with attributes width and height
3. Explain the attributes with example
4. Write a function called distance_between_points that takes two points as
arguments and returns distance between them by passing instance as an
argument
5. Explain the ways of modifying the state of an object with suitable example for
each of them.
6. Write a function named grow_rectangle that takes a Rectangle and two
attributes width and height .It should modify the width and height of rectangle
7. Demonstrate the concept of shallow copy and deep copy used to copy an
object with a suitable example.
8. write a function called print_time that takes a Time object and prints it in the
form hour:minute:second.
9. Demonstrate the pure functions with suitable example.
10. Use the datetime module to write a program that gets the current date and
prints the day of the week.
11. Develop a program defining str methods for time objects
12. write an add method for Points that works with either a Point object or a tuple
13. Explain the concept of polymorphism in Object oriented programming.
14. Write a definition for a class named Kangaroo with the following methods:
An__init__ method that initializes an attribute named pouch_contents to an
empty list.
15. Explain the following with example:
1.__init__
2.self

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy