Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Student Name:Uzair Mustafa

Student No:10521254

Pesudo code:
Section 1 Function:
def compareWords(word1,word2)
Set matchCount to 0
For I in range of length of word2
If word1[i] == word2[i]
Set matchCount++
Return matchCount

Section 2:
Declare/Set 100 word in wordscandidate
While true
Display welcome to word guess game 2021
Display choose difficulty level “e’’,”E”,”H’’,”h”,”M’’,”m”
Prompt for difficulty level choice
If choice==’e’ or ‘E’
Display difficulty level
Select 7 words randomly from candidate words to wordlist
Set guesses_remaining to 5
ElseIf choice==’’m’’ or ‘M’
Display difficulty level
Select 8 words randomly from candidate words to wordlist
Set guesses_remaining to 4
ElseIf choice==’H’ or ‘h’
Display difficulty level
Select 9 words randomly from candidate words to wordlist
Set guesses_remaining to 3
ElseIf choice is not “e’’,’’E’’,’’M’’,’’m”,’’H’’,”h” prompt invalid choice enter again
End while
Select randomly a word as a password from wordlist
Set won to False

While guesses_remainging>=0 and won is false


For I enumerate in wordlist
Display list of words
End For
Prompt user to enter a guess
Display word entered by user
Call comparewords function to get matchcount
If matchcount ==password length
Display password is correct
Set won to True
If matchcount=!password length
Display password incorrect
Display how many letters are correct
Reduce guesses_remaining by 1
End While
If guesses_remaining==0
Display you ran out of guesses
Display You loose
If Won==True
If guesses_remaining==guess
Display lucky guess you guessed word in first guess
Display Congragulation you won!

You might also like