k so mabey i lied about when i posted this before but then i read the rules of homework yh so sorry guys.dont judge me for lieing .
this is the homework:
Noel is creating a music quiz game.
The game stores a list of song names and their artist
(e.g. the band or solo artist name). The player needs to
try and guess the song name.
The game is played as follows:
• A random song name and artist are chosen.
• The artist and the first letter of each word in the song title are displayed.
• The user has two chances to guess the name of the song.
• If the user guesses the answer correctly the first time, they score 3 points. If the user guesses
the answer correctly the second time they score 1 point. The game repeats.
• The game ends when a player guesses the song name incorrectly the second time.
Only authorised players are allowed to play the game.
Where appropriate, input from the user should be validated.
Design, develop, test and evaluate a system that:
1. Allows a player to enter their details, which are then authenticated to ensure that they are an
authorised player.
2. Stores a list of song names and artists in an external file.
3. Selects a song from the file, displaying the artist and the first letter of each word of the song title.
4. Allows the user up to two chances to guess the name of the song, stopping the game if they guess
a song incorrectly on the second chance.
5. If the guess is correct, add the points to the player’s score depending on the number of guesses.
6. Displays the number of points the player has when the game ends.
7. Stores the name of the player and their score in an external file.
8. Displays the score and player name of the top 5 winning scores from the external file.
this is what i done so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
def menu():
print ( "welcome to the music guessing on python " )
time.sleep( 1 )
print ( "you must be logged in to take the quiz" )
time.sleep( 1 )
while True :
username = input ( "please enter username" )
if username = = "hi" :
print ( "username is correct" )
break
else :
print ( "Incorrect username Try again." )
while True :
password = input ( "please enter password" )
if password = = "hi" :
print ( "password is correct" )
break
else :
print ( "Incorrect password Try again." )
print ( "you are now logged in" )
score = 0
print ("")
artist1 = [ 'Michael Jackson' ]
song1 = [ 'Billy Jean' ]
def guess1artist1():
print ( "guess the name of the artist,in 3 guesses" )
time.sleep( 1 )
print ( "guess1,first letter of name is" ,artist1[ 0 ][ 0 ])
print ( "clue :he was born on:29 August 1958,he died on 25 June 2009" )
guess1 = input ( "please enter guess,(Capital Leters For Names)" )
if guess1 ! = "Michael Jackson" :
print ( "incorrect guess,2 more guesses left" )
if guess1 = = "Michael Jackson" :
print ( "correct guess" )
score = score + 3
def guess2artist1():
print ( "guess2,seccond letter of name is" ,artist1[ 0 ][ 1 ])
guess2 = input ( "please enter guess,(Capital Leters For Names)" )
if guess2 ! = "Michael Jackson" :
print ( "incorrect guess,1 more guesses left" )
if guess2 = = "Michael Jackson" :
print ( "correct guess" )
score = score + 2
def guess3artist1():
print ( "guess3,third letter of name is" ,artist1[ 0 ][ 2 ])
guess3 = input ( "please enter guess,(Capital Leters For Names)" )
if guess3 ! = "Michael Jackson" :
print ( "incorrect guess,0 more guesses left" )
if guess3 = = "Michael Jackson" :
print ( "correct guess" )
score = score + 1
print ( "Score:" ,score)
def guess1song1():
print ( "now you have 3 guesses to guess 1 of his songs" )
time.sleep( 1 )
print ( "guess1,first letter of song is" ,song1[ 0 ][ 0 ])
guess1 = input ( "please enter guess,(Capital Leters For Names)" )
if guess1 ! = "Billy Jean" :
print ( "incorrect guess,2 more guesses left" )
if guess1 = = "Billy Jean" :
print ( "correct guess" )
score = score + 3
def guess2song1():
print ( "guess2,seccond letter of name is" ,song1[ 0 ][ 1 ])
guess2 = input ( "please enter guess" )
if guess2 ! = "Billy Jean" :
print ( "incorrect guess,1 more guesses left" )
if guess2 = = "Billy Jean" :
print ( "correct guess" )
score = score + 2
def guess3song1():
print ( "guess3,third letter of name is" ,song1[ 0 ][ 2 ])
guess3 = input ( "please enter guess" )
if guess3 ! = "Billy Jean" :
print ( "incorrect guess,0 more guesses left" )
print ( "Score:" ,score)
if guess3 = = "Billy Jean" :
print ( "correct guess" )
score = score + 1
import time
guess1artist1()
guess2artist1()
guess3artist1()
guess1song1()
guess2song1()
guess3song1()
|
Output:
Score: 0
guess the name of the artist,in 3 guesses
guess1,first letter of name is M
clue :he was born on:29 August 1958,he died on 25 June 2009
please enter guess,(Capital Leters For Names)m
incorrect guess,2 more guesses left
guess2,seccond letter of name is i
please enter guess,(Capital Leters For Names)mi
incorrect guess,1 more guesses left
guess3,third letter of name is c
please enter guess,(Capital Leters For Names)michael
incorrect guess,0 more guesses left
now you have 3 guesses to guess 1 of his songs
guess1,first letter of song is B
please enter guess,(Capital Leters For Names)b
incorrect guess,2 more guesses left
guess2,seccond letter of name is i
please enter guessi
incorrect guess,1 more guesses left
guess3,third letter of name is l
please enter guessl
incorrect guess,0 more guesses left
Traceback (most recent call last):
File "N:\J276 PROGRAMMING PROJECT\Task1.py", line 146, in <module>
guess3song1()
File "N:\J276 PROGRAMMING PROJECT\Task1.py", line 130, in guess3song1
print("Score:",score)
UnboundLocalError: local variable 'score' referenced before assignment
>>>