# Question & Answer: Assignment 1 CSSE1001/7030 Semester 2, 2017 Version 1.0.0 10 marks Due Friday 25 August, 2017, 21:30 1……

Assignment 1 CSSE1001/7030 Semester 2, 2017 Version 1.0.0 10 marks Due Friday 25 August, 2017, 21:30 1. Introduction For this assignment, you are required to write Python code to implement a word guessing game 1.1. Game Rules The game involves trying to guess an unknown word. The guessing of the word is done in 11 steps In Step 1 of the game the player guesses a 2 letter sub-word corresponding to the first two letters of the unknown word. They score 20 points for any of the guessed letters which are in the word (but not in the correct position) and 100 points for any letter in the correct position (See, for example, line 1 of Table 1-the unknown word is “castle”). In Step 2 the player guesses a 3 letter sub-word to correspond to the first three letters of the unknown word (See, for example, line 2 of Table 1). In Step 3 the player suggests another 3 letter sub-word to correspond to letters 2 to 4 of the unknown word, and the usual scoring system holds (See line 3 of Table 1). In Step 4 the player suggests another 3 letter sub-word to correspond to letters 3 to 5 of the unknown word (See line 4 of Table 1). In Step 5 they guess a 3 letter sub-word to correspond to letters 4 to 6 of the unknown word. (See line 5 of Table 1). The player continues guessing sub-words according to the zig-zagging pattern shown in Table 1 until they have a final chance to guess the complete unknown word (which in the example below is ‘castle). Table 1 (Unknown word is “castle Step number Step-by-step Letter Guesses 40 120 140 20 220 240 420 10 260 600

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Assignment 1 CSSE1001/7030 Semester 2, 2017 Version 1.0.0 10 marks Due Friday 25 August, 2017, 21:30 1……
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

#

# Start here

#

import random

print(‘Welcome to the brain teasing Zig-Zag word game’)

name = input(‘What is your name? ‘)

fname,lname = name.split(‘ ‘)

with open(“words.txt”,”r”) as wordsFile:

while ” in lines:

lines.remove(”)

pos = random.randint(1,len(lines)-1)

p_word = lines[pos]

print(f”hi {fname}! We have selected {len(p_word)} letter word for you to guess”)

print(“Let the game begin”)

p_word = list(p_word)

word_progress = [‘_’ for i in range(len(p_word))]

wrong_guess = 6

solved = 0

print(‘Wrong guesses left : ‘,wrong_guess)

print(‘Word progress : ‘,”.join(word_progress))

while wrong_guess > 0:

guess = input(‘Guess a letter : ‘)

if guess in p_word:

word_progress[p_word.index(guess)] = guess

print(‘Yes!’)

else:

wrong_guess -= 1

print(‘NOPE!’)

if word_progress == p_word:

print(f'{fname} wins! ‘)

exit()

print(‘Wrong guesses left : ‘,wrong_guess)

print(‘Word progress : ‘,”.join(word_progress))

print(f'{fname} Lose !’)

Indentations:

Output: