Task 1 Task 2 Task 3
Task 1 Task 2 Task 3

Task 1

This is a string.

Look at this code. Predict what will be printed and write down your prediction.

a = newString[0]

b = newString[-1]

c = newString[-5:]

d = newString[:-5]

e = newString[10:16]

print(f"{a} : {b} : {c} : {d} : {e})

Now, put the code into your IDE and see if you are correct.

Task 2

An array of STRINGS stores 6 words.

The computer program counts how many of the words end in the letter s

Write this program.

Task 3 - Super Tricky - have a go!

A game allows a user to guess which color the computer is thinking of. The user has only 3 chances to guess correctly.

Type this code and test it in your IDE. It has no syntax errors so it should run when you have finished.

Run the code a few times and see if it works.

To help you complete the following tasks, type print(compColor) after compColor is assigned randomly.

  1. Add the color "pink" to the array. Do you need to update any more code in program so that "pink" is sometimes chosen randomly?
  2. Change the program so that the user has 5 chances instead of 3.
  3. Add an IF statement inside the while loop: if the first letter of the guess is the same as the first letter of the computer's color, a message So close! is displayed.
  4. Also, IF the length of the guess is the same as the length of the computer's color, a message Nice try! appears.
  5. Finally, if the user enters BLUE or Blue and the computer's color is blue, the user should still win! Can you figure out how to code this in the program?