Csp1150 - programming principles - you are required to


Assignment Overview

You are required to design and implement an "English Test" program in which the user is presented with a word and then asked to answer a simple question about the word. After 5 words, the program shows the user's score and ends.

The 5 words are selected at random from the list of words in the starter file (english_test.py) provided to you with this assignment brief. Please use the starter file as the basis of your assignment code.

For each of the 5 words, the program randomly selects one of the following 4 questions to ask:

1) How many letters does the word contain?

2) How many vowels does the word contain?

3) How many consonants does the word contain?

4) What is letter # of the word? (# is a number, e.g. "What is letter 3 of the word?")

The entirety of this program can be implemented in under 125 lines of code (although implementing CSP5110 or optional additions may result in a program longer than this) - Ask your tutor for advice if you feel your program is unusually long or inefficient.

Program Requirements

The requirements begin where the starter file ends - after defining the "candidateWords" list. In the following information, numbered points describe a requirement of the program, and bullet points (in italics) are additional details, notes and hints regarding the requirement. Ask your tutor if you do not understand the requirements or would like further information.

1. Print a welcome message, and then set up the test by creating a list of 5 randomly selected words from candidateWords. Also create an integer variable for the user's score (set it to 0).
- This assignment brief will assume variable names of "wordList" and "score" for the variables mentioned above. Individual words in wordList will be referred to as "word".
- The wordList is created for you as part of the code provided in the english_test.py starter file.
- The "random.sample()" function can be used to randomly select a number of items from a list.

2. Enter a loop that repeats once for each word in wordList.
- Using a "for" loop and the "enumerate()" function is an effective way to loop through the words in wordList. See Lecture 3, Slide 38 for an example of this.
The body of this loop must...

Print the current word as well as the number of the word, e.g. "Word 1/5: HELLO".

Generate a random number between 1 and 4, and use it to choose which question is asked.

If the random number is 1, ask the user "How many letters does the word contain?" and prompt them for input. Assess their answer, and then print an appropriate message.
- Remember to convert the user's response to an integer so that you can assess it correctly.
- If the user answers correctly, remember to add 1 to the score variable. If they answer incorrectly, remember to show the correct answer as part of the "Incorrect!" message.

If the random number is 2, ask the user "How many vowels does the word contain?" and prompt them for input. Assess their answer, and then print an appropriate message.
- Remember to convert the user's response to an integer so that you can assess it correctly.
- Use the "countVowels" function (detailed below) to determine the correct answer.
- If the user answers correctly, remember to add 1 to the score variable. If they answer incorrectly, remember to show the correct answer as part of the "Incorrect!" message.

If the random number is 3, ask the user "How many consonants does the word contain?" and prompt them for input. Assess their answer, and then print an appropriate message.
- Remember to convert the user's response to an integer so that you can assess it correctly.
- Use the "countVowels" function here as well - all letters that are not vowels are consonants.
- If the user answers correctly, remember to add 1 to the score variable. If they answer incorrectly, remember to show the correct answer as part of the "Incorrect!" message.

If the random number is 4, randomly select a number within the length of the word, (e.g. if the word is HOUSE, a number between 1 and 5) and use it to ask the user "What is letter # of the word?", where "#" is the selected number. Prompt the user for input, assess their answer, and then print an appropriate message.
- Convert the user's response to uppercase so that you can assess it regardless of case.
- If the user answers correctly, remember to add 1 to the score variable. If they answer incorrectly, remember to show the correct answer as part of the "Incorrect!" message.

3. The last thing the program should do (after the body of the loop described in Requirement 2) is print a "Game Over" message that includes the user's score out of 5.


Attachment:- english-test.rar

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Csp1150 - programming principles - you are required to
Reference No:- TGS01566671

Expected delivery within 24 Hours