Python program

profileTranger
final-exam.pdf

NTEC361 - Final Exam (100 points)

I’m thinking of a number …

Using the pseudo code below, write the Python program as described. Paste the code to Canvas using http://hilite.me/ (100 points)

import random

chances = 4 turn = 0 storage = []

# create a secret random number between 1 and 21 secret = ①

# print a welcome message ②

# while the user is still playing the game while True:

  # ask the user for `input` and store the result as an integer   num = ③

  # Quit the program on `any` of the following IF conditions:   # IF the user enters "Q" ④   # IF the user has guessed the `secret` number ⑤   # IF the user has used up all the `chances` ⑥

  if num == "Q": ...

  # Only if the both 7 AND 8 IF condtions are True:   # IF input value is greater then 0: ⑦   # IF num is not already in storage: ⑧   # Add the num to the storage ⑨   # Increment turn by 1 ⑩   # (hint: only when both 7, 8 are True: 9, 10 are executed)

① hint: use a method in the random library

② You may print any welcome message you like

I’m thinking of a number … | 1

  • Untitled
  • I’m thinking of a number …​