T Program-16
TASK:16. Write a Python script to count number of characters, number of
uppercase letters, number of lowercase letters, number of vowels, number
of digits, number of spaces and number of other characters present in disk
file '[Link]'
OBJECTIVE: To understand the concept of open(), close(), reading of text
file using read() function and nested if-else.
CODE
FILE
OUTPUT
Program-17
TASK: 17. Write a Python script to replace all occurrence of 'he' with 'she'
in a text file '[Link]'
OBJECTIVE: To understand the concept of multiple files handing in Python.
CODE
FILE
OUTPUT
Program-18
TASK:18. Assuming that a text file named [Link] already contains
some text written into it, write a function named vowelwords(), that reads
the file [Link] and creates a new file named [Link], which shall
contain only those words from the file [Link] which don’t start with an
uppercase vowel (i.e., with ‘A’, ‘E’, ‘I’, ‘O’, ‘U’). For example, if the file
[Link] contains Carry Umbrella and Overcoat When It rains. Then the
text file [Link] shall contain Carry and When rains
OBJECTIVE: To understand the concept of multiple files handing in Python
CODE
OUTPUT
FILE 1
FILE 2
Program-19
TASK:19. Write a function in PYTHON to count the number of lines ending
with a vowel from a text file '[Link]'
OBJECTIVE: To understand the working of readlines() function.
CODE
OUTPUT
FILE
Program-20
TASK: 20. Read a text file([Link]) line by line and display each word
separated by a #.
OBJECTIVE: To understand the working of readline() function.
CODE
OUTPUT
FILE
Program-21
TASK: 21. Given a binary file “[Link]”, containing records of the
following type: [Admno, Name, Per] Where these three values are: Admno
– Admission Number of student (integer) Name -- Name of student (string)
Per – Marks percentage of student (float) Write a Python script to write the
details of students in a binary file. Also read contents of the file
“[Link]” and display the details of those students whose
percentage is above 75.
OBJECTIVE: To understand the concept of binary file with [Link]()
[Link]() method.
CODE
OUTPUT
Program-22
TASK: 22. Write a menu driven program for the binary file [Link]
storing the objects of following type: {"ID":integer, "GIFT":string,
"Cost":float} i) To write the objects of above type in binary file ii) To read
and display all the objects iii) To update an object for a given ID. iv) To
delete an object for a given ID.
OBJECTIVCE: To understand the concept of read/write/update/delete
records from a binary file using dictionary as record object.
CODE
OUTPUT
Program-23
TASK: 23. Write a menu driven program to read/write data in CSV
file([Link]) also display number of records in CSV file. Suppose CSV file
contain following data:
1,John,john@[Link],24,programmer 2,Bob,bob@[Link],34,designer
3,Mary,mary@[Link],43,sales 4,Raj Kumar, raj@[Link],34,data
analysist 5,Kerry, kerry@[Link],24,developer
OBJECTIVE: To understand the concept of [Link](), [Link](),
writerow() or writerows() functions of csv module.
CODE
OUTPUT
Program-24
TASK: 24. Write a Program to read CSV file([Link]) and display the
details those authors who have written their book in the year 1991.
Suppose CSV file contain following data: Programming language, Designed
by, Appeared, Extension Python, Guido van Rossum, 1991, .py Java, James
Gosling, 1995, .java C++, Bjarne Stroustrup, 1985, .cpp C, Yashwant
Kanetkar, 1980, .c
OBJECTIVE: To understand the concept of [Link](), [Link](),
writerow() or writerows() functions of csv module.
CODE
OUTPUT
FILE
Program-25
TASK:25. program to read and display CSV file([Link]) without
heading and avoid blank lines between records.
OBJECTIVE: To understand the concept of [Link](), next(), header in
csv file.
CODE
OUTPUT
FILE
Program-26
TASK: 26. Write a program to implement a stack using a list.
OBJECTIVE: To understand the concept of STACK(LIFO).
CODE
Output