import getpass

def q_w_r(question, answer):
    print(question)
    res = input(question)
    if res == answer:
        print(res + " is correct! Nice job.")
        points = 1
    else:
        print("Sorry that's not right. Next question!")
        points = 0
    return points

questions = 4
score = 0

print('Hello, ' + getpass.getuser() + "! Welcome to my quiz. :)")

print("Do you want to take the quiz? (y/n)")
reply = input("Do you want to take the quiz? (y/n)")

if reply == "n":
    print("Alright then, have a nice day!")
    quit()
else:
    print("Alright! You will be asked " + str(questions) + " questions about python terms. Let's get started!")

#questions 1-4
score += q_w_r("Q1: What symbol do you use to concatinate/combine two strings?:", "+")

score += q_w_r("Q2: How do you check if a string consists of all lowercase letters?:", "islower" )

score += q_w_r("Q3: What function do you use to get user input?:", "input")

score += q_w_r("Q4: How do you define a function or method?:", "def")

print("Nice try, " + getpass.getuser() + "! You scored " + str(score) +"/" + str(questions) + " on this quiz.")
Hello, aliyatang! Welcome to my quiz. :)
Do you want to take the quiz? (y/n)
Alright! You will be asked 4 questions about python terms. Let's get started!
Q1: What symbol do you use to concatinate/combine two strings?:
+ is correct! Nice job.
Q2: How do you check if a string consists of all lowercase letters?:
islower is correct! Nice job.
Q3: What function do you use to get user input?:
input is correct! Nice job.
Q4: How do you define a function or method?:
Sorry that's not right. Next question!
Nice try, aliyatang! You scored 3/4 on this quiz.