0% found this document useful (0 votes)
3 views3 pages

Programming_PWP

The document contains a list of programming tasks and questions related to Python, covering various topics such as classes, file handling, data structures, exceptions, and user-defined packages. Each task requires the implementation of specific functionalities or the demonstration of concepts like inheritance, palindrome checking, and random number generation. The tasks are designed to test and enhance programming skills in Python.

Uploaded by

ksach225
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)
3 views3 pages

Programming_PWP

The document contains a list of programming tasks and questions related to Python, covering various topics such as classes, file handling, data structures, exceptions, and user-defined packages. Each task requires the implementation of specific functionalities or the demonstration of concepts like inheritance, palindrome checking, and random number generation. The tasks are designed to test and enhance programming skills in Python.

Uploaded by

ksach225
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/ 3

Programming questions

1 Write a program to print following :

2 Write a program to create class EMPLOYEE with ID and NAME and display its
contents.
3 Write a program for importing module for addition and substraction of two
numbers.
4 Write a program to create dictionary of students that includes their ROLL NO.
and NAME.
i) Add three students in above dictionary
ii) Update name = ‘Shreyas’ of ROLL NO = 2
iii) Delete information of ROLL NO = 1
5 Write a program illustrating use of user defined package in python.
6 a) Write the output of the following :
i) >>> a = [ 2, 5, 1, 3, 6, 9, 7 ]
>>> a [ 2 : 6 ] = [ 2, 4, 9, 0 ]
>>> print (a)
ii) >>> b = [ “Hello” , “Good” ]
>>> b. append ( “python” )
>>> print (b)
iii)>>> t1 = [ 3, 5, 6, 7 ]
>>> print ( t1 [2] )
>>> print ( t1 [–1] )
>>> print ( t1 [2 :] )
>>> print ( t1 [ : ] )
7 Write a program to open a file in write mode and append some contents at the
end of file.
8 Write a program to implement the concept of inheritance in python.
9 Write down the output of the following Python code
>>>indices=['zero','one','two','three','four','five']
i) >>>indices[:4]
ii) >>>indices[:-2]
10 Write a Python program to find the factorial of a number provided by the user.
11 Write a python program to input any two tuples and interchange the tuple
variables.
12 Write a program to show user defined exception in Python.
13 Write a Python Program to check if a string is palindrome or not.
14 Write a Python program to calculate sum of digit of given number using function.
15 Write a Python Program to accept values from user in a list and find the largest
number and smallest number in a list.
16 Write python program to display output like.

17 Write python program using module, show how to write and use module by
importing it.
18 T = (‘spam’, ‘Spam’, ‘SPAM!’, ‘SaPm’)
print (T [2] )
print (T [-2] )
print (T [2:] )
print (List (T) )
19 WAP to read contents of first.txt file and write same content in second.txt file
20 Write a program illustrating use of user defined package in python.
21 Write a program to create class student with Roll no. and Name and display its
contents.
22 Write program to implement concept of inheritance in python
23 Print the following pattern using loop:

24 Write python program to perform following operations on set.


i) Create set of five elements
ii) Access set elements
iii) Update set by adding one element
iv) Remove one element from set
25 What is the output of the following program?
dict1 = {‘Google’ : 1, ‘Facebook’ : 2, ‘Microsoft’ : 3}
dict2 = {‘GFG’ : 1, ‘Microsoft’ : 2, ‘Youtube’ : 3}
dict1⋅update(dict2);
for key, values in dictl⋅items( ):
print (key, values)
26 Write a python program that takes a number and checks whether it is a
palindrome.
27 Write a python program to create a user defined module that will ask your
program name and display the name of the program.
28 Write a python program takes in a number and find the sum of digits in a
number.
29 Write a program function that accepts a string and calculate the number of
uppercase letters and lower case letters.
30 Write a python program to create class student with roll-no and display its
contents.
31 Write the output for the following if the variable course = “Python”
>>> course [ : 3 ]
>>> course [ 3 : ]
>>> course [ 2 : 2 ]
>>> course [ : ]
>>> course [ -1 ]
>>> course [ 1 ]
32 Write a python program to generate five random integers between 10 and 50
using numpy library
33 Write a Python program to create a class ‘Diploma’ having a method
‘getdiploma’ that prints “I got a diploma”. It has two subclasses namely ‘CO’ and
‘IF’ each having a method with the same name that prints “I am with CO
diploma” and ‘I am with IF diploma’ respectively. Call the method by creating an
object of each of the three classes.
34 Write a Python program to create user defined exception that will check whether
the password is correct or not.
35 Write a program illustrating use of user defined package in Python.
36 Write a Python program to check for zero division errors exception.
37 Write the output for the following if the variable fruit = ‘banana’.
>> fruit [:3]
>> fruit [3:]
>> fruit [3:3]
>> fruit [:]
38 Write a Python program to read contents from “a.txt” and write same contents in
“b.txt”.
39 Write a Python program to read contents of first.txt file and write same content
in second.txt file

You might also like