#imports the libary
import getpass, sys 
#defines the function
#promt is the questions
def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg
#variables
questions = 7
correct = 0
#into words
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
print("Are you ready to take a test?")

quest = [ "What command is used to include other functions that were previously developed?","What command is used to evaluate correct or incorrect response in this example?","Each 'if' command contains an '_________' to determine a true or false condition?","What key word in python defines a function?","What key word turns a variable into a string?","what command stores what the user types?","what command is followed b 'if'?"]

Answers = {
    "0" : ["import","Import"],
    "1" : ["if", "If"],
    "2" : ["expression","Expression"],
    "3" : ["def","Def"],
    "4" : ["str","Str"],
    "5" : ["input","Input"],
    "6" : ["else","Else"]
}

q = -1

while q <6:
    q += 1
    rsp = question_with_response(quest[q])
    if rsp in Answers[str(q)]:
        print( rsp + " is correct")
        correct += 1
    else:
        print( rsp +(" is incorrect"))

# the value in the variable correct is divided by the value in the variable question and then multiplied by 100
# this value is saved in the variable percentage
percentage = correct/questions *100

if percentage < 50:
    print(getpass.getuser() + " You failed")
else:
    print(getpass.getuser() +" You passed")


#getpass.getuser() takes the user name  and str converts the variable correct into a string
#this is the same with the variable question
print( " you scored " + str(correct) +"/" + str(questions))
print("or " + str(percentage) +"%")
# To show the percentage, the calculated value in the variable "percentage" then convert into a string 
Hello, varunm running /bin/python
You will be asked 7 questions.
Are you ready to take a test?
Question: What command is used to include other functions that were previously developed?
import is correct
Question: What command is used to evaluate correct or incorrect response in this example?
If is correct
Question: Each 'if' command contains an '_________' to determine a true or false condition?
else is incorrect
Question: What key word in python defines a function?
Def is correct
Question: What key word turns a variable into a string?
ds is incorrect
Question: what command stores what the user types?
Str is incorrect
Question: what command is followed b 'if'?
else is correct
varunm You passed
 you scored 4/7
or 57.14285714285714%
#imports the libary
import getpass, sys 
#defines the function
#promt is the questions
def question_with_response(prompt):
    print("Question: " + prompt)
    msg = input()
    return msg
#variables
questions = 7
correct = 0
#into words
print('Hello, ' + getpass.getuser() + " running " + sys.executable)
print("You will be asked " + str(questions) + " questions.")
print("Are you ready to take a test?")

question = {
    "quest": [ "What command is used to include other functions that were previously developed?","What command is used to evaluate correct or incorrect response in this example?","Each 'if' command contains an '_________' to determine a true or false condition?","What key word in python defines a function?","What key word turns a variable into a string?","what command stores what the user types?","what command is followed b 'if'?"]
    
}
Answers = {
    "answer_1" : ["import","Import"],
    "answer_2" : ["if", "If"],
    "answer_3" : ["expression","Expression"],
    "answer_4" : ["def","Def"],
    "answer_5" : ["str","Str"],
    "answer_6" : ["input","Input"],
    "answer_7" : ["else","Else"]
}





rsp = question_with_response(question["quest"][0])
if rsp in Answers["answer_1"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    
rsp = question_with_response(question["quest"][1])
if rsp in Answers["answer_2"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    
rsp = question_with_response(question["quest"][2])
if rsp in Answers["answer_3"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    
rsp = question_with_response(question["quest"][3])
if rsp in Answers["answer_4"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    
rsp = question_with_response(question["quest"][4])
if rsp in Answers["answer_5"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    
    
rsp = question_with_response(question["quest"][5])
if rsp in Answers["answer_6"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    
rsp = question_with_response(question["quest"][6])
if rsp in Answers["answer_7"]:
    print( rsp + " is correct")
    correct += 1
else:
    print( rsp +(" is incorrect"))
    

# the value in the variable correct is divided by the value in the variable question and then multiplied by 100
# this value is saved in the variable percentage
percentage = correct/questions *100

if percentage < 50:
    print(getpass.getuser() + " You failed")
else:
    print(getpass.getuser() +" You passed")


#getpass.getuser() takes the user name  and str converts the variable correct into a string
#this is the same with the variable question
print( " you scored " + str(correct) +"/" + str(questions))
print("or " + str(percentage) +"%")
# To show the percentage, the calculated value in the variable "percentage" then convert into a string 



Hello, varunm running /bin/python
You will be asked 7 questions.
Are you ready to take a test?
Question: What command is used to include other functions that were previously developed?
 is incorrect
Question: What command is used to evaluate correct or incorrect response in this example?
If is correct
Question: Each 'if' command contains an '_________' to determine a true or false condition?
expression is correct
Question: What key word in python defines a function?
Def is correct
Question: What key word turns a variable into a string?
str is correct
Question: what command stores what the user types?
input is correct
Question: what command is followed b 'if'?
Else is correct
varunm You failed
 you scored 0/7
or 0.0%