Assignment 4
Assignment 4
ASSIGNMENT- 4
• This assignment is my original work and no part of it has been copied from any other student’s work or from
any other source except where due acknowledgment is made.
• No part of this assignment has been written for me by any other person except where such collaboration has
been authorized by the faculty concerned and must be clearly acknowledged.
• I give permission to copy the marked work to be retained in the department for NBA requirement.
• I understand plagiarism and obey the academic ethics.
• I understand that academic misconduct is a punishable offence.
COs
Addressed Total
Max
Marks
Marks
Obtained
Remarks:
Signature
Faculty: Binu VP
1. Write commands for the following
2. Use dictionary comprehension to create a dictionary with numbers (key) and its squares(values).
3. Read a string and find the frequency of occurrence of each character in it. Use dictionary.
4. Create a dictionary with binary equivalent of all hexa decimal digits. Use this dictionary to convert the given
hexadecimal number into binary.
5.Find the frequency of occurrence of words in a sentence. Also print the words with highest freq
Files
1.Copy one file to another
4. Read numbers stored in one file and store the sorted numbers in another file after deleting duplicates.
5.List of numbers are stored in a file(num.dat). Create two file Prime ( containing prime numbers) and composite(
containing composite numbers) from the numbers stored in num.dat
6.Find the words having largest frequency from the given file.
7.Create a data file in the following format (r.no, name.m1, m2, m3 marks out of 50) 1|aswith|30|40|50 Write
scripts for the following
a) Print the r.no, name and Tot marks in the descending order of total marks (Rank list)
b) Print the list of passed students (marks >=25 for all three subjects)
c) Print the pass percentage in each subject
d)List of students having 80% or more in all the three subjects
8. Write a Python program to create a text file. Read the contents of the file, encrypt every character in the file with
a distance of 3 and write it to a new file. Eg: yak is encrypted as bdn
9.A text file contains the keyword mec replace all occurrence of the word mec with MEC