# computer science who can fix my python code

Watch
Announcements
#1
hey guys i got this python code that i dont know how to do a function. it has 2 attempt to answer a question before it moves onto the next. so i want it on the first attempt to earn 10 points but if on the second attempt 5 point but if they get it wrong its 0 points. at the end it prints out their score.
Score = 0
i = 0
while i < 3:
song = input("Guess the song title S... R.....'s' Theme Song?:")
if song == "Seth Rollins Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made Seth Rollins Theme Song ? \n A. The Miz \n B. Mickie James \n C. Brock Lesnar \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title The U......... Theme Song?:")
if song == "The Undertaker's Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made The Undertaker Theme Song ? \n A. Ultimate Warrior \n B. Shawn Michaels \n C. Kane \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title S.... C... S.... A..... Song?:")
if song == "Stone Cold Steve Austin Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made Stone Cold Steve Austin Theme Song ? \n A. Sycho Sid \n B. Bret Hart \n C. The Brothers of Destruction \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title C. P... Theme Song?:")
if song == "CM Punk Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made CM Punk Theme Song ? \n A. D - Generation X \n B. Chris Benoit \n C. The NWO \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title T..... H Theme Song?:")
if song == "Triple H Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made Triple H Theme Song ? \n A. Trish Stratus \n B. Johncena \n C. AJ Style \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
print("Your Score out of 10 is",Score )
0
9 months ago
#2
It looks like a good start. To properly debug you'll need to include the indentation. What problem are you having when running it?
0
9 months ago
#3
(Original post by Lily09897)
hey guys i got this python code that i dont know how to do a function. it has 2 attempt to answer a question before it moves onto the next. so i want it on the first attempt to earn 10 points but if on the second attempt 5 point but if they get it wrong its 0 points. at the end it prints out their score.
Score = 0
i = 0
while i < 3:
song = input("Guess the song title S... R.....'s' Theme Song?:")
if song == "Seth Rollins Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made Seth Rollins Theme Song ? \n A. The Miz \n B. Mickie James \n C. Brock Lesnar \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title The U......... Theme Song?:")
if song == "The Undertaker's Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made The Undertaker Theme Song ? \n A. Ultimate Warrior \n B. Shawn Michaels \n C. Kane \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title S.... C... S.... A..... Song?:")
if song == "Stone Cold Steve Austin Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made Stone Cold Steve Austin Theme Song ? \n A. Sycho Sid \n B. Bret Hart \n C. The Brothers of Destruction \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title C. P... Theme Song?:")
if song == "CM Punk Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made CM Punk Theme Song ? \n A. D - Generation X \n B. Chris Benoit \n C. The NWO \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
song = input("Guess the song title T..... H Theme Song?:")
if song == "Triple H Theme Song":
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
i = 0
while i < 3:
answer1 = input("Who made Triple H Theme Song ? \n A. Trish Stratus \n B. Johncena \n C. AJ Style \n Answer: ")
print("That's the correct song")
break
else:
i += 1
if i == 3:
print("Too many attempts")
break
else:
print(f"That's the wrong song, you have {3-i} attempts left")
print("Your Score out of 10 is",Score )
Did u try running it?
0
#4
It looks like a good start. To properly debug you'll need to include the indentation. What problem are you having when running it?
i don't have any syntax/logic errors but i want to add a scoring system of how at the first attempt of the python program it will give 10 point but at the second attempt there's 5 point but if they get it wrong there is 0 points.
0
#5
(Original post by the_pharaoh)
Did u try running it?
guys i don't have errors on this i just want to add a scoring system of how at the first attempt of the python program it will give 10 point but at the second attempt there's 5 point but if they get it wrong there is 0 points.
0
9 months ago
#6
(Original post by Lily09897)
guys i don't have errors on this i just want to add a scoring system of how at the first attempt of the python program it will give 10 point but at the second attempt there's 5 point but if they get it wrong there is 0 points.
make a variable that stores the number of atempts then make an if statement with the conditions u just stated also make a total score variable so you can add the score after each question
0
#7
(Original post by the_pharaoh)
make a variable that stores the number of atempts then make an if statement with the conditions u just stated also make a total score variable so you can add the score after each question
hey it was so hard for me can you do an example so i can fully understand it plz.
0
9 months ago
#8
(Original post by Lily09897)
hey it was so hard for me can you do an example so i can fully understand it plz.
ok let's see so at the beginning you will add the following variables:
no_attempts = 0
total_score = 0

ok this is harder than i thot ok before we do the scoring system I want u to put each question in a loop where the loop gives the user 3 times to answer the question before moving onto the next or if the user gets the answer correct so it will look smthn like this:

the question
user_input
is statement to check if the answer is correct
no_attempts = no_attempts + 1
if statement for if the number of attempts is 1:
output
if statement for if the number of attempts is 2:
output
if statement for if the number of attempts is 3:
output

ok i feel like i waffled too much hope u understood
0
#9
(Original post by the_pharaoh)
ok let's see so at the beginning you will add the following variables:
no_attempts = 0
total_score = 0

ok this is harder than i thot ok before we do the scoring system I want u to put each question in a loop where the loop gives the user 3 times to answer the question before moving onto the next or if the user gets the answer correct so it will look smthn like this:

the question
user_input
is statement to check if the answer is correct
no_attempts = no_attempts + 1
if statement for if the number of attempts is 1:
output
if statement for if the number of attempts is 2:
output
if statement for if the number of attempts is 3:
output

ok i feel like i waffled too much hope u understood
thanks so much as i have copy and pasted the python program could you put your program into mine i am really confused on where to put your program onto mine program.
0
9 months ago
#10
(Original post by Lily09897)
thanks so much as i have copy and pasted the python program could you put your program into mine i am really confused on where to put your program onto mine program.
sigh ill tru cuz honestly when i look at pre made code i cant understand anything especially considering u used i instead of acc variable names
0
9 months ago
#11
(Original post by the_pharaoh)
sigh ill tru cuz honestly when i look at pre made code i cant understand anything especially considering u used i instead of acc variable names
(Original post by the_pharaoh)
no_attempts = no_attempts + 1
if statement for if the number of attempts is 1:
output
if statement for if the number of attempts is 2:
output
if statement for if the number of attempts is 3:
output
basically just add this part after every question but put it inside the loop
0
#12
(Original post by the_pharaoh)
basically just add this part after every question but put it inside the loop
can you show me an example using one of my question in the python program.
0
9 months ago
#13
(Original post by Lily09897)
can you show me an example using one of my question in the python program.
(Original post by Lily09897)
Score = 0
i = 0
while i < 4 and song != "Seth Rollins Theme Song" :
song = input("Guess the song title S... R.....'s' Theme Song?:")
if song == "Seth Rollins Theme Song":
print("That's the correct song")
i = i + 1
else:
print"that is incorrect try again"
i = i + 1
if i == 1:
print("you scored 10 point")
score = score + 10
elif i == 2:
print("you scored 5 point")
score = score + 5
else:
print("you scored 0 points")
score = score + 0

here u go i completely updated ur code
0
#14
(Original post by the_pharaoh)
here u go i completely updated ur code
hey there can you do it with indents its still not work on python saying sytax errors.
0
9 months ago
#15
(Original post by Lily09897)
hey there can you do it with indents its still not work on python saying sytax errors.
Nah I'm sorry at this point I'm doing everything for u it's not hard to figure it out plus I'm at school so I can't
0
8 months ago
#16
This should help.
0
#17
ok guys i will make it easier just convert this python code to flowchart. i will do the rest please i beg you.

score = 0
i=0
song=0
while (i < 2 and song != "Seth Rollins Theme Song") :
song = input("Guess the song title S... R.....'s' Theme Song?: ")
if (song == "Seth Rollins Theme Song"):
print ("That's the correct song!")
i=i+1
else:
print("That is incorrect, please try again")
i=i+1
if i == 1:
print ("You scored 5 points")
score = score + 10
else:
print ("You scored 0 points")
score = score + 0
Score = 0
i = 0
while i < 2 and answer1 != "B and C":
answer1 = input("Who made Seth Rollins Theme Song ? \n A. The Miz \n B. Mickie James \n C. Brock Lesnar \n Answer: ")
print("That's the correct song!")
if i == 0:
Score = Score + 10
elif i == 1:
Score = Score + 5
else:
Score = Score + 0
i = 5
else:
print("That is not correct")
i = i+1

print ("Your total score is", Score)
0
8 months ago
#18
Wait.... I wrote that! Give me credit or I will report you!
0
X

new posts
Back
to top
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

### Poll

Join the discussion

#### Would you give consent for uni's to contact your parent/trusted person in a mental health crisis?

Yes - my parent/carer (64)
32.65%
Yes - a trusted person (54)
27.55%
No (52)
26.53%
I'm not sure (26)
13.27%