Quiz

 try:

p='Hello World'[::-1]

questions={

"What is a correct syntax to output 'Hello World' in Python?":

["a) echo 'Hello World'","b) p 'hello World'","c) print('hello')","d) echo('Hello World')"],


"How do you insert COMMENTS in Python code ?":

["a) /*This is a coment*/","b)#This is a coment","c)//This is a coment"],


"Guess the output \nprint('Hello World'[::-1])":

["a)"+p,'b)Hello Worl',"c)d","d)Error"],


"Which of the following is not a complex number?":

["a)k = 2+3j","b)k = complex(2, 3)","c)k = 2 + 3i","d)k = 2+3J"],


"How do you create a variable with the numeric value 5?":

["a)x=5","b)x=int(5)","c)x=float(5)","d)All are correct"]


}

ans=["c","b","a","c","d"]

q=list(questions.keys()) 

score=0

n=len(questions)

for x in range(n):

print(q[x])

for y in questions[q[x]]:

print(y)

t=input("Enter your option ").lower()

if t==ans[x]:

score+=1


print("-------------")


print("score is ",score,"out of",n)

except Exception as e:

print(e)