184k views
0 votes
Write a code in python that asks and answers the question

What is the largest planet in our solar system?

User Nekia
by
6.9k points

1 Answer

4 votes

Answer:

question = "What is the largest planet in our solar system?"

answer = "Jupiter"

user_input = input(question)

if user_input.lower() == answer.lower():

print("That's correct!")

else:

print("Sorry, that's incorrect. The correct answer is", answer)

Step-by-step explanation:

In this code, we first define the question and answer as variables. Then we use the input() function to prompt the user to enter an answer to the question. We convert the user's input to lowercase using the lower() method to make the comparison case-insensitive.

We then use an if statement to check if the user's input matches the correct answer. If it does, we print a message indicating that the user is correct. If the user's input does not match the correct answer, we print a message indicating that the user is incorrect and we provide the correct answer.

User David Carroll
by
7.5k points