Skip to content

Instantly share code, notes, and snippets.

View VinayReddy-Vangala's full-sized avatar

Vinay Reddy Vangala VinayReddy-Vangala

View GitHub Profile
@VinayReddy-Vangala
VinayReddy-Vangala / 7.1.py
Created February 11, 2022 17:24
7.1 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case. Use the file words.txt to produce the output below.
# Use words.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
for line in fh:
stripped_line=line.strip()
print(stripped_line.upper())
@VinayReddy-Vangala
VinayReddy-Vangala / 9.4.py
Created February 11, 2022 17:23
9.4 Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of times they a…
name = input("Enter file:")
if len(name) < 1:
name = "mbox-short.txt"
handle = open(name)
kv_book=dict()
list1=[]
for line in handle:
if line.startswith('From '):
split=line.split()
list1.append(split[1])