Python Forum
i lied it is homework and i need help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i lied it is homework and i need help
#6
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:
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 >>>
Reply


Messages In This Thread
i lied it is homework and i need help - by JamieBR56 - May-24-2019, 11:48 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020