Python Program List
Python Program List
COMPUTER SCIENCE
PYTHON PRACTICAL PROGRAM LIST
Session: 2021-22
TERM I
1 Write a Program that reads a date as an integer in the format MMDDYYYY.The program will print
the date in the format <Month Name><day>, <year>
Sample output:
Enter Date:12252019
December 25, 2019
2 Create a dictionary whose keys are month names and whose values are the number of days in the
corresponding months.
a) Ask the user to enter a month name and use the dictionary to tell them how many days are
in the month.
b) Print out all of the keys in alphabetical order.
c) Print out all of the months with 31 days.
d) Print out the key – value pairs sorted by the number of days in each month.
3. Write a function nthRoot() that receives two parameters x and n and returns nth root of x i.e X 1/n
The default value of n is 2
Write a program to find nth root by invoking nth Root( )
Program should run till user wants to continue.
4 Write a function named volumeBox( ) to calculate and return the volume of a box.
function should have the following input parameters.
a) Length of box
b) Width of box
c) Height of box
Default values for Length, Width and Height parameters are 1,1,1
Write a program to find volume of a box by invoking volumeBox( )
Program should run till user wants to continue.
5 Write a function calci() to calculate addition,subtraction,multiplication,division of two numbers
and return the results to calling function.
Write a program to call calci() and print the results.
Program should run till user wants to continue.
6 Write Python functions for the following
i) A function cubeN() that takes a number as argument and calculates and prints cube of it . If
there is no value passed to the function then function should calculate cube of 2.
ii) A function checkS() that accepts two strings and compares them. If both are equal prints ‘True’
otherwise prints ‘False’
Write a Menu driven program to invoke the above two functions.
7 Write a random number generator that generates random numbers between 1 and 6 (simulates a
dice)
8 Create a binary file with name and roll number. Search for a given roll number and display the
name, if not found display appropriate message.
9 Create a CSV file by entering user-id and password, read and search the password for given userid.
10 Write a program to count ‘He’ or ‘His’ present in the text file ‘story.txt’.
story.txt file content:
King Krishnadevaraya loved horses and had the best collection of horse breeds in the Kingdom.
Well, one day, a trader came to the King and told him that he had brought with him a horse of
the best breed in Arabia.
He invited the King to inspect the horse. King Krishnadevaraya loved the horse; so the trader
said that the King could buy this one and that he had two more like this one, back in Arabia
that he would go back to get. The King loved the horse so much that he had to have the other
two as well. He paid the trader 5000 gold coins in advance. The trader promised that he would