+1(978)310-4246 credencewriters@gmail.com



Write a program to capitalise each word in a phrase unless the word is an escaping word like a, an, the, am, is, are, and, of, in, on, with, from, to. For example, if given the input message “I am a good player”, your program should return “I am a Good Player” at output. A skeleton program is provided in the following cell and you need to complete the empty function for word capitalisation.

Hint: you can create a list of the escape words given above and decide if a new word is an escape word by searching the list

In [ ]:

def capitalise(phrase):
# your code goes here to perform the word capitalisation

Some calls to the


function you have defined above are provided for you below. The expected output of the cell below is:

I am an Educator and a Researcher
Big Data is the Future of Information Technology
He Wants to Have Breakfast with Her in the Hotel

In [ ]:

capitalise(“I am an educator and a researcher”)
capitalise(“big data is the future of information technology”)
capitalise(“He wants to have breakfast with her in the hotel”)


File Word Count

For this exercise, you will complete a program that displays top 10 most frequently occurring words in an input file. We will use the same test file


as used in a previous problem. A skeleton program is provided in the following cell, where the sorting and displaying functionality has already been implemented. You need to complete the


function which creates a dictionary of key value pairs given input file name passed to the function. Each entry in the dictionary has a key, which is a word that appeared in the input file, and a value, which is the number of occurrences of that word in the input file. Your program should return this dictionary. Note that any return value of your function other than dictionary will cause the rest part of the program to fail.


You can create an empty dictionary with either of the following syntax:

d = dict()


d = {}


Adding new key-value pairs to an existing dictionary uses the same syntax as updating an existing entry:

d[‘newKey’] = value

. However, if you wish to access an existing entry, you need to make sure the key already exists in the dictionary. e.g.

d[‘newKey’] = d[‘newKey’] + 1

will fail if


is not already in the dictionary as the right-hand-side of the assignment is attempting to


a non-existant entry.

You can check if a key already exists in a dictionary by using the


operator. e.g.

d = {‘building’: ‘EB’, ‘floor’: ‘1’, ‘room’: 48}
if ‘floor’ in d:
print(“The floor is”, d[‘floor’])

In [ ]:

def create_wordcount_dict(filename):
# Your code goes here to create and return a dictionary
wordcount = create_dict(“bigdata.txt”)

# sort the entries in the dictionary by their values in descending order i.e. value in the key-value pair
# note that the return value is a list of keys only which is assigned to sorted_keys_list
sorted_keys_list = sorted(wordcount, key=wordcount.get, reverse=True)

# print the top 10 entries in the sorted list
for key in sorted_keys_list[:10]:
print(key, wordcount[key])

Unit ID, unit name, course name 301046, Big Data, MICT 300581, Programming Techniques, BICT 300144, Object Oriented Analysis, BICT 300103, Data
Structure, BCS 300147, Object Oriented Programming, BCS 300569, Computer Security, BIS 301044, Data Science, MICT 300582, Technologies for Web
Applications, BICT

Purchase answer to see full

error: Content is protected !!