4 python questions

#QUESTION 1 Go to https://www.gutenberg.org/ (Links to an external site.)Links to an external site. select a free ebook and download the plain text file.

Write a program that does the following:

  • Read in your ebook (any book, any language)
  • Break the book into word
  • Make a dictionary of all words and how often they occur: for instance if the word ‘the’ happened 2000 time and the word ‘a’ happened 1940 times word_dict= {‘the’ : 2000, ‘a’ :1940}
  • Print the dictionary of word frequencies to a file (freqs.txt) with the most frequent at the top and least frequent at the bottom

Turn in your python code firstname.lastname.py, your freqs.txt file, and a copy of your ebook(the input file)

………….

to sort by value

<code><span class="kwd">import</span> operator sorted_dict <span class="pun">=</span> sorted<span class="pun">(my_dict</span><span class="pun">.</span><span class="pln">items</span><span class="pun">(),</span> key<span class="pun">=</span><span class="pln">operator</span><span class="pun">.</span><span class="pln">itemgetter</span><span class="pun">(</span><span class="lit">1</span><span class="pun">))</span></code>

#QUESTION 2

#make the following function print the right answer

def year_of_birth(age,current_year):

print(year_of_birth(21,2017))

#QUESTION 3

# define a list that contains your favorite food

# Ask the User for their favorite food

# Add it to the list

# print out the list using a loop such as

#THE NEW COLORS OF THE RAINBOW ARE

#1:food 1

#2:food 2

#3:food 3

#4:food 4

#5:whatever the user entered

#Bonus 2 points print in reverse order as well

#QUESTION 4

#ask the User to add one topping to the pizza

#modify to dictionary to have that item

#print out every topping the pizza contains

#”this pizza contains Topping 1,Topping 2…Topping 3 (including the topping the

user added”

toppings={‘peperoni’:True,’olives’:False,”pineapple”:True,”sausage”:False,”jalapeno

s”:False}

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.