Have been helping granddaughter to get started with Python and she has written a little program (below) which looks good but must have a flaw somewhere as final answer is always zero. Can anyone see where the error is? Thanks.
name = input("Hello, what is your name?")
print(name, ",welcome to the car quiz!")
first_answer = 2
score = 0
input("Q1 - Which country does Porsche come from?")
input("1 - England")
input("2 - Germany")
input("3 - Austria")
input("4 - Portugal")
user1 = input("Enter your answer:")
if user1 == first_answer:
score = score + 1
else:
score = score + 0
second_answer = 4
input("Q2 - Which is the fastest road car?")
input("1 - Ferrari")
input("2 - Lamborghini")
input("3 - McLaren")
input("4 - Bugatti")
user2 = input("Enter your answer:")
if user2 == second_answer:
score = score + 1
else:
score = score + 0
third_answer = 1
input("Q3 - Where doe Kia Motors come from?")
input("1 - South Korea")
input("2 - China")
input("3 - America")
input("4 - Japan")
user3 = input("Enter your answer:")
if user3 == third_answer:
score = score + 1
else:
score = score + 0
fourth_answer = 1
input("Q4 - Which of these is a British car company?")
input("1 - Jaguar")
input("2 - Ford")
input("3 - Ferrari")
input("4 - Hyundai")
user4 = input("Enter your answer:")
if user4 == fourth_answer:
score = score + 1
else:
score = score + 0
fifth_answer = 3
input("Q5 - Where was Ferrari created?")
input("1 - America")
input("2 - Canada")
input("3 - Italy")
input("4 - Spain")
user5 = input("Enter your answer:")
if user5 == fifth_answer:
score = score + 1
else:
score = score + 0
print(name, "has a score of", score)
Have been helping granddaughter to get started with Python and she has written a little program (below) which looks good but must have a flaw somewhere as final answer is always zero. Can anyone see where the error is? Thanks.
name = input("Hello, what is your name?")
print(name, ",welcome to the car quiz!")
first_answer = 2
score = 0
input("Q1 - Which country does Porsche come from?")
input("1 - England")
input("2 - Germany")
input("3 - Austria")
input("4 - Portugal")
user1 = input("Enter your answer:")
if user1 == first_answer:
score = score + 1
else:
score = score + 0
second_answer = 4
input("Q2 - Which is the fastest road car?")
input("1 - Ferrari")
input("2 - Lamborghini")
input("3 - McLaren")
input("4 - Bugatti")
user2 = input("Enter your answer:")
if user2 == second_answer:
score = score + 1
else:
score = score + 0
third_answer = 1
input("Q3 - Where doe Kia Motors come from?")
input("1 - South Korea")
input("2 - China")
input("3 - America")
input("4 - Japan")
user3 = input("Enter your answer:")
if user3 == third_answer:
score = score + 1
else:
score = score + 0
fourth_answer = 1
input("Q4 - Which of these is a British car company?")
input("1 - Jaguar")
input("2 - Ford")
input("3 - Ferrari")
input("4 - Hyundai")
user4 = input("Enter your answer:")
if user4 == fourth_answer:
score = score + 1
else:
score = score + 0
fifth_answer = 3
input("Q5 - Where was Ferrari created?")
input("1 - America")
input("2 - Canada")
input("3 - Italy")
input("4 - Spain")
user5 = input("Enter your answer:")
if user5 == fifth_answer:
score = score + 1
else:
score = score + 0
print(name, "has a score of", score)
Have been helping granddaughter to get started with Python and she has written a little program (below) which looks good but must have a flaw somewhere as final answer is always zero. Can anyone see where the error is? Thanks.
name = input("Hello, what is your name?")
print(name, ",welcome to the car quiz!")
first_answer = 2
score = 0
input("Q1 - Which country does Porsche come from?")
input("1 - England")
input("2 - Germany")
input("3 - Austria")
input("4 - Portugal")
user1 = input("Enter your answer:")
if user1 == first_answer:
score = score + 1
else:
score = score + 0
second_answer = 4
input("Q2 - Which is the fastest road car?")
input("1 - Ferrari")
input("2 - Lamborghini")
input("3 - McLaren")
input("4 - Bugatti")
user2 = input("Enter your answer:")
if user2 == second_answer:
score = score + 1
else:
score = score + 0
third_answer = 1
input("Q3 - Where doe Kia Motors come from?")
input("1 - South Korea")
input("2 - China")
input("3 - America")
input("4 - Japan")
user3 = input("Enter your answer:")
if user3 == third_answer:
score = score + 1
else:
score = score + 0
fourth_answer = 1
input("Q4 - Which of these is a British car company?")
input("1 - Jaguar")
input("2 - Ford")
input("3 - Ferrari")
input("4 - Hyundai")
user4 = input("Enter your answer:")
if user4 == fourth_answer:
score = score + 1
else:
score = score + 0
fifth_answer = 3
input("Q5 - Where was Ferrari created?")
input("1 - America")
input("2 - Canada")
input("3 - Italy")
input("4 - Spain")
user5 = input("Enter your answer:")
if user5 == fifth_answer:
score = score + 1
else:
score = score + 0
print(name, "has a score of", score)
