Exercise 4: Download a copy of the file from www.py4e.com/code3/romeo.txt Write a program to open the file romeo.txt and read it line by line. For each line, split the line into a list of words using...

1 answer below »
Exercise 4: Download a copy of the file from www.py4e.com/code3/romeo.txt Write a program to open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split function. For each word, check to see if the word is already in a list. If the word is not in the list, add it to the list. When the program completes, sort and print the resulting words in alphabetical order. Enter file: romeo.txt ['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder']
Please attach a word doc with the program before and after it runs similar to the attached.


Program: from tkinter import * from tkinter import messagebox def interface(): def clicked(): try: n = int(number_of_people.get()) no_of_vans = int(n/10) number_of_vans_label = Label(screen, text = 'Number of vans: '+str(no_of_vans)) number_of_vans_label.grid(column = 0, row = 3) number_of_people_remaning = n%10 number_of_people_remaning_label = Label(screen, text = 'Number of people remaining: '+str(number_of_people_remaning)) number_of_people_remaning_label.grid(column = 0, row =4) except: messagebox.showerror('Vans & More Depot','Enter int value for passengers') screen = Tk() screen.title("Vans & More Depot") screen.geometry('350x200') number_of_people_label = Label(screen, text = 'Enter the number of people: ') number_of_people_label.grid(column = 0, row = 1) number_of_people = Entry(screen, width = 20) number_of_people.grid(column = 1, row = 1) button = Button(screen, text="Calculate", command=clicked) button.grid(column=1, row=2) screen.mainloop() interface() Screenshots of the Program running with the GUI:
Answered 3 days AfterApr 19, 2021

Answer To: Exercise 4: Download a copy of the file from www.py4e.com/code3/romeo.txt Write a program to open...

Neha answered on Apr 22 2021
152 Votes
81214 - python code/code.py
#to store each word of the file
lst = []
#take file name as input fro
m user
filename = input("Please enter file name: ")
#open file to read
with open(filename,'r') as file:
# read each line from the file
for line in file:
# read each word from the line
for word in line.split():
#add each word in the list
lst.append(word)

#list to store words with single existence
res = []
#each...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here