You are on page 1of 3

ASSIGNMENT 3

PYTHON FUNCTION BASED PROGRAMS


Sr. Title of program
no.
1 Write a Python function to find the Max of three numbers
2 Write a Python function to sum all the numbers in a list
3 Write a Python function to multiply all the numbers in a list
4 Write a Python program to reverse a string
5 Write a Python function to calculate the factorial of a number (a non-negative
integer). The function accepts the number as an argument
6 Write a Python function to check whether a number falls in a given range
7 Write a Python function that accepts a string and calculate the number of upper
case letters and lower case letters
Sample String : 'The quick Brow Fox'
Expected Output :
No. of Upper case characters : 3
No. of Lower case Characters : 12
8 Write a Python function that takes a list and returns a new list with unique
elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]
9 Write a Python function that takes a number as a parameter and check the
number is prime or no
10 Write a Python program to print the even numbers from a given list.
11 Write a Python function that checks whether a passed string is palindrome or
not.
12 Write a Python function to create and print a list where the values are square of
numbers between 1 and 30 (both included)
13 Write a Python program to access a function inside a function.
14 Define a function that accepts 2 values and return its sum, subtraction and
multiplication
15 Define a function that accepts roll number and returns whether the student is
present or absent
16 Define a function which counts vowels and consonant in a word.
17 Define a function that returns Factorial of a number
18 Define a function that accepts radius and returns the area of a circle.
19 Write a Python Program to Exchange the Values of Two Numbers
20 Write a python Program to print multiplication table of any number

ASSIGNMENT 4
FILE HANDLING IN PYTHON

1 Write a python program to find longest word from text file


2 Write a Python Program to Count the Number of Words in a Text File
3 program to read text file line by line and store it into an array
4 python program to write student record into binary file
5 Write a python program to delete student data from binary file
6 Write a python program to modify or update student record in binary file
7 Write a python program to search binary file for student record
8 Write a python program to create list of email-ids and write it into text file
9 Write python program to read specific columns in CSV file
10 Write a python program to write python list to CSV file
11 A file sports.dat contains information in following format :
Event ~ Participant

Write a function that would read contents from file sports.dat and creates a file
named Atheletic.dat copying only those records from sports.dat where the
event name is "Atheletics".
12 Write a program to count the words "to" and "the" present in a text file
"Poem.txt".
13 Write a program that copies one file to another. Have the program read the file
names from user ?
14 Write a function in Python to count and display the number of lines starting with
alphabet 'A' present in a text file " LINES.TXT". e.g., the file "LINES.TXT" contains
the following lines:
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets & numbers are allowed in password.
The function should display the output as 3.
15 A file contains a list of telephone numbers in the following form:
Arvind 7258031
Sachin 7259197
The names contain only one word the names and telephone numbers are
separated by white spaces Write program to read a file and display its contents
in two columns.
16 Write a program that appends the contents of one file to another. Have the
program take the filenames from the user
17 Write a method/function DISPLAYWORDS() in python to read lines from a text
file STORY.TXT, and display those words, which are less than 4 characters.
18 Consider the following definition of dictionary Member, write a method in
python to write the content in a pickled file member.dat.
Member = {'MemberNo.': _____, 'Name': _____}
19 Consider the following definition of dictionary Staff, write a method in python to
search and display the content in a pickled file staff.dat, where Staffcode key of
the dictionary is matching with 'S0105'.

Staff = {‘Staff Code': _____, 'Name' = _____}


20 Write a function in to search and display details of all trains, whose destination
is Delhi from a binary file TRAIN.DAT. Assuming the binary file is containing the
objects of the following dictionary type:
Train = { 'Tno': ___, ‘From’: ____, 'To' : ____}
21 A binary file "Book.dat" has structure [BookNo, Book Name, Author, Price].
(i) Write a user defined function CreateFile() to input data for a record and add
to Book.dat.
(i) Write a function CountRec(Author) in Python which accepts the Author name
as parameter and count and return number of books by the given Author are
stored in the binary file "Book.dat".
22 Write a Python program to read a given CSV file having tab delimiter.

You might also like