Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This code must be written in python 3 and must include document the program usin

ID: 3786981 • Letter: T

Question

This code must be written in python 3 and must include document the program using Python comments. Write an interactive true/false quiz. The program should ask the user three true/false questions about any topic you like. The user should be given n chances to take the quiz, where n is a number given by the user. The program should keep track of how many questions the user answered correctly (for a single attempt) and should keep track of the attempt number. After each quiz attempt, the program will print out a score.

Your program must meet the following specifications:
1. Get the number of attempts, n, from the user.
2. Ask three (nicely formatted) true/false questions and give feedback for each question.
3. Track the number of correct answers for each quiz attempt.
4. Track the attempt number.
5. Print out the score (i.e., number correct) for each attempt. Also include the attempt number. 6. Document the program using Python comments.

Here is a sample run of the program.

1) True

1) True

Explanation / Answer

The following code gives you the required functionality, save your code with .py extension and verify the correctness of the program:

# prompting user to enter the no. of times he/she wants to take quiz
n = int(input('How many times you want?'))

i=1

while(i<=n):
   count = 0       #to track the no. of correct answers
   print("Letâs start the quiz! Good luck!")
  
   #Question no. 1
   print("1. The syntax of a programming language is its meaning.")
   print("1) True")
   print("2) False")

# promting user to enter the given question
   res = int(input('What is your answer?'))
   if res ==1:
       print("Thatâs incorrect. The syntax of a programming language is its form, and semantics is its meaning.")
   else:
       print("Thatâs correct!")
       count = count + 1
  
   #Question no. 2
   print("2. An algorithm can be written without using a programming language.")
   print("1) True")
   print("2) False")

# promting user to enter the given question
   res = int(input('What is your answer?'))
   if res == 2 :
       print("Thatâs incorrect. An algorithm can be written in pseudocode - precise English that describes what a program does.")
   else:
       print("Thatâs correct!")
       count = count + 1
      
   #Question no. 3
   print("The name _myVar is a valid identifier in Python.")
   print("1) True")
   print("2) False")

# promting user to enter the given question

   res = int(input('What is your answer?'))
   if res ==2:
       print("Thatâs incorrect. An algorithm can be written in pseudocode - precise English that describes what a program does.")
   else:
       print("Thatâs correct!")
       count = count + 1
   print("On attempt #" + str(i) +" you got " + str(count) +" out of 3 correct.")
   i = i + 1
  

Input:

2
1
2
1
2
1
2

Output:

How many times you want?Let’s start the quiz! Good luck!
1. The syntax of a programming language is its meaning.
1) True
2) False
What is your answer?That’s incorrect. The syntax of a programming language is its form, and semantics is its meaning.
2. An algorithm can be written without using a programming language.
1) True
2) False
What is your answer?That’s incorrect. An algorithm can be written in pseudocode - precise English that describes what a program does.
The name _myVar is a valid identifier in Python.
1) True
2) False
What is your answer?That’s correct!
On attempt #1 you got 1 out of 3 correct.
Let’s start the quiz! Good luck!
1. The syntax of a programming language is its meaning.
1) True
2) False
What is your answer?That’s correct!
2. An algorithm can be written without using a programming language.
1) True
2) False
What is your answer?That’s correct!
The name _myVar is a valid identifier in Python.
1) True
2) False
What is your answer?That’s incorrect. An algorithm can be written in pseudocode - precise English that describes what a program does.
On attempt #2 you got 2 out of 3 correct.

Link of the original code:

http://ideone.com/tB9k50

Hope it helps, do give your response.