COMP 1001B– W19 – A4 Due Thursday, March 21st at 11:55 PM 1 Assignment 4 Lists and Strings Submit a single zip file called assignment4.zip. This zip file should contain all the files you create as...

I would like two quotes for problem 1 and 2 and/or a quote for both


COMP 1001B– W19 – A4 Due Thursday, March 21st at 11:55 PM 1 Assignment 4 Lists and Strings Submit a single zip file called assignment4.zip. This zip file should contain all the files you create as part of this assignment. Each question will specify the name of the file you should create. Make sure you name your files precisely. This assignment has 50 marks. See the marking scheme that is posted on the assignment page for details. Problem 1 (Mastermind) For this question you will create a version of the popular game mastermind! Go here to play an online version of the game: Mastermind online (Note, the game you make will look and behave differently). You should save your game program in a file called a4q1.py. The rules for your game are as follows: • You randomly generate a password of 5 digits between [0-9]. (e.g.: [3,1,4,4,2]) • The user then has 10 turns to guess the password. • Each turn the user makes one guess, and your program reports how many digits were correct. o Note: a correct guess is the right number in the right location. o Note: be careful with datatypes! Make sure you are comparing strings with strings, and integers with integers. • If the user guesses all five digits correctly, the game ends with a win message. • If the user runs out of turns, the game ends with a lose message. You may assume that the user correctly enters 5 integers, however you must allow them to enter all 5 into a single prompt, separated by spaces. Tip: the string.split() method might be useful here. Example Game Output (text entered by the user is highlighted): I've set my password, enter 5 digits in the range [0-9] separated by spaces (e.g. 1 3 2 4 4): 10 guesses remaining > 1 2 3 4 5 1 of 5 correct 9 guesses remaining > 2 3 4 5 1 0 of 5 correct 8 guesses remaining > 2 2 3 4 5 1 of 5 correct 7 guesses remaining > 3 3 3 4 5 http://www.web-games-online.com/mastermind/index.php COMP 1001B– W19 – A4 Due Thursday, March 21st at 11:55 PM 2 1 of 5 correct 6 guesses remaining > 4 4 4 4 5 2 of 5 correct 5 guesses remaining > 5 5 4 5 5 1 of 5 correct 4 guesses remaining > 3 2 1 4 5 2 of 5 correct 3 guesses remaining > 1 1 1 4 5 3 of 5 correct 2 guesses remaining > 2 1 1 4 5 3 of 5 correct 1 guesses remaining > 3 1 3 4 5 2 of 5 correct You'll never get my treasure because the password was ['4', '1', '1', '2', '5'] Problem 2 (File Analysis) For this problem, create a file named a4q2.py. Within this file, write a program that does the following: 1. Ask a user for a filename 2. Open the specified file 3. Print out the following information: a. The total number of words in the file b. A list of the longest words in the file (the greatest number of characters) c. A list of the shortest words in the file (the least number of characters) d. The average word length of all words in the file 4. Close the specified file For the purposes of this assignment, you can assume that a single word is any text contained between spaces. This may include punctuation – for example, the text “didn’t” would be considered a single word, as would the text “cold,”. Your lists of longest/shortest words should not contain any duplicates (remember, ‘A’ and ‘a’ are not considered duplicates). On the assignment page, there are 5 test files that you can use (fileanalysisX.txt) along with a summary of the expected output (fileanalysisX-expectedoutput.txt). You can use these files to verify your results. Note: you do not need to write files that match the expected output files – they are just copies of the correct printed output (i.e., your printed information should look the same). Remember to break the problem down and approach it in a similar fashion to the previous assignment. Example Program Output (text entered by the user is highlighted): COMP 1001B– W19 – A4 Due Thursday, March 21st at 11:55 PM 3 Enter the filename: fileanalysis0.txt Total Words: 208 Longest Words List: ['predominates', 'particularly', 'questionable'] Smallest Words List: ['I', 'a'] Average Word Length: 4.399038461538462 Total Unique Words: 136
Mar 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here