Question: Problem 1: (9 points) Create a list containing 10 zeros. Do this three different ways. In [ ]: # write your code here Problem 2:
Problem 1: (9 points) Create a list containing 10 zeros. Do this three different ways.
In [ ]:
# write your code here
Problem 2: (6 points) Consider two lists A and B such that A returns [1,2,3] and B returns [1,2,3].
Create A and B so A is B returns True.
Create A and B so A is B returns False.
In [ ]:
# write your code for part 1 here
In [ ]:
# Write your code for part 2 here
Problem 3: (15 points) Write a function that takes in a string as input and returns a list of the unique letters used in the string. Punctuation should not be counted as a unique letter. For our purposes you may consider the following characters as punctuation: .,;:?!- Your list should return all letters as lower case and sorted. So for example if the input is ' Happy days are here again!' your function should return the list ['a''d','e','g','h','i','n','p','r','s','y']
In [ ]:
# write your code here # you may add more cells as needed
Problem 4: (70 points)
Scrabble Help: The file dictionary.txt contains all of the words in the Official Scrabble Player's Dictionary, Second Edition. (Note this list contains some offensive language.) Write the following functions in Python. Each function uses the parameter file_name which will be the name of the file containing the dictionary. Your functions must work with any file_name so this should just be a string representing the name of a file in the same directory (folder) as your function. So to test your functions, download the dictionary.txt file into the same directory as your notebook.
length_n(file_name, n): returns alist of all words of length n.
starts_with(file_name, n, first_letter): returns a list of all words of length n beginning with the letter first_letter
contains_letter(file_name, n, included): returns a list of words of length n containing the letter included but not beginning with it.
In [ ]:
def length_n(file_name,n): # your code here
In [ ]:
def starts_with(file_name, n, first_letter): # your code here
In [ ]:
def contains_letter(file_name, n, included): # your code here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
