import getpass, sys

def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg

questions = 4
correct = 0

print("Hello, you will be asked " + str(questions) + " questions.")
ready = input("Are you ready to take the test?")

rsp = question_with_response("What is the fastest land animal?")
if rsp == "cheetah":
    print(rsp + " is correct!")
    correct += 1
else:
    print("Your answer is incorrect!")

rsp = question_with_response("What is the tallest animal in the world?")
if rsp == "giraffe":
    print(rsp + " is correct!")
    correct += 1
else:
    print("Your answer is incorrect")

rsp = question_with_response("What is the most common animal to have as a pet in the US.")
if rsp == "dog" or rsp == "dogs":
    print(rsp + " is correct!")
    correct += 1
else:
    print("Your answer is incorrect!")

rsp = question_with_response("What is the largest land animal")
if rsp == "elephant":
    print(rsp + " is correct!")
    correct += 1
else:
  print("Your answer is incorrect!")
  
print("You scored " + str(correct) + "/" + str(questions))
Hello, you will be asked 4 questions.
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/Users/sachit/vscode/fastpages-sachit-blog/_notebooks/2022-08-29-Python_Quiz.ipynb Cell 2 in <cell line: 12>()
      <a href='vscode-notebook-cell:/Users/sachit/vscode/fastpages-sachit-blog/_notebooks/2022-08-29-Python_Quiz.ipynb#W1sZmlsZQ%3D%3D?line=8'>9</a> correct = 0
     <a href='vscode-notebook-cell:/Users/sachit/vscode/fastpages-sachit-blog/_notebooks/2022-08-29-Python_Quiz.ipynb#W1sZmlsZQ%3D%3D?line=10'>11</a> print("Hello, you will be asked " + str(questions) + " questions.")
---> <a href='vscode-notebook-cell:/Users/sachit/vscode/fastpages-sachit-blog/_notebooks/2022-08-29-Python_Quiz.ipynb#W1sZmlsZQ%3D%3D?line=11'>12</a> ready = input("Are you ready to take the test?")
     <a href='vscode-notebook-cell:/Users/sachit/vscode/fastpages-sachit-blog/_notebooks/2022-08-29-Python_Quiz.ipynb#W1sZmlsZQ%3D%3D?line=13'>14</a> rsp = question_with_response("What is the fastest land animal?")
     <a href='vscode-notebook-cell:/Users/sachit/vscode/fastpages-sachit-blog/_notebooks/2022-08-29-Python_Quiz.ipynb#W1sZmlsZQ%3D%3D?line=14'>15</a> if rsp == "cheetah":

File ~/Library/Python/3.8/lib/python/site-packages/ipykernel/kernelbase.py:1177, in Kernel.raw_input(self, prompt)
   1173 if not self._allow_stdin:
   1174     raise StdinNotImplementedError(
   1175         "raw_input was called, but this frontend does not support input requests."
   1176     )
-> 1177 return self._input_request(
   1178     str(prompt),
   1179     self._parent_ident["shell"],
   1180     self.get_parent("shell"),
   1181     password=False,
   1182 )

File ~/Library/Python/3.8/lib/python/site-packages/ipykernel/kernelbase.py:1219, in Kernel._input_request(self, prompt, ident, parent, password)
   1216             break
   1217 except KeyboardInterrupt:
   1218     # re-raise KeyboardInterrupt, to truncate traceback
-> 1219     raise KeyboardInterrupt("Interrupted by user") from None
   1220 except Exception:
   1221     self.log.warning("Invalid Message:", exc_info=True)

KeyboardInterrupt: Interrupted by user