I’m trying something new with these types of problems, so please
provide feedback if
you have any. If you work through the “Build a Trivia Game”
problems throughout the
course’s tutorials, by the end of the course you will have created
a trivia game that
retrieves questions from the Internet, keeps track of a user’s
score throughout a game,
and remembers the high scores forever.
This week, we will start with a simplified version of a trivia game
(decomposition!) and
continue to add details in future weeks. For this week, write a
program that prints out a
single trivia question that you made up, gets an answer from the
user, and then tells
them if they were correct or not.
One thing you may want to consider is case sensitivity (e.g.,
“Ottawa” is not equal to
“ottawa”). We will talk about handling string data in more detail
later, but for now all you
need to know is that Python has a way to convert strings to
lower/upper case. If x is a
5
string variable, then x.upper() evaluates to the uppercase version
of x. There is also
x.lower(). So if x = “Ottawa” and y = “otTAwa”, x does not equal y,
but x.lower() equals
y.lower(). Like the int/float/str type conversions, this does not
actually change the value
of x but only evaluates to the lowercase representation of x.
question = input("\nWho is the President of America? ")
answer = "donald trump"
question = question.lower()
if(question == answer):
print("Correct answer!")
else:
print("Incorrect answer!")
******************************************************************* SCREENSHOT*********************************************************



I’m trying something new with these types of problems, so please provide feedback if you have any. If you work through the “Build a Trivia Game” problems throughout the course’s tutorials, by the end...