Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 9 months ago
#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: ")
if answer1 == "A" or answer1 == "The Miz":
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: ")
if answer1 == "B" or answer1 == "Shawn Michaels":
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: ")
if answer1 == "C" or answer1 == "The Brothers of Destruction":
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: ")
if answer1 == "B" or answer1 == "The NWO":
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: ")
if answer1 == "A" or answer1 == "Trish Stratus":
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
reply
physgradstudent
Badges: 11
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report 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: ")
if answer1 == "A" or answer1 == "The Miz":
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: ")
if answer1 == "B" or answer1 == "Shawn Michaels":
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: ")
if answer1 == "C" or answer1 == "The Brothers of Destruction":
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: ")
if answer1 == "B" or answer1 == "The NWO":
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: ")
if answer1 == "A" or answer1 == "Trish Stratus":
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
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#4
Report Thread starter 9 months ago
#4
(Original post by physgradstudent)
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
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#5
Report Thread starter 9 months ago
#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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#6
Report 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
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#7
Report Thread starter 9 months ago
#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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#8
Report 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:

while no_attempts < 4 and user_answer != correct_answer:
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
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#9
Report Thread starter 9 months ago
#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:

while no_attempts < 4 and user_answer != correct_answer:
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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#10
Report 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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#11
Report 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
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#12
Report Thread starter 9 months ago
#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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#13
Report 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
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#14
Report Thread starter 9 months ago
#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
reply
the_pharaoh
Badges: 21
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#15
Report 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
reply
lstocber
Badges: 14
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#16
Report 8 months ago
#16
This should help.
Attached files
0
reply
Lily09897
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#17
Report Thread starter 8 months ago
#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
answer1 = " "
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: ")
if answer1 == "A":
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
reply
lstocber
Badges: 14
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#18
Report 8 months ago
#18
Wait.... I wrote that! Give me credit or I will report you!
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

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

Personalise

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%

Watched Threads

View All
Latest
My Feed