MCQ Game with Python

# Creating a function to give options
def give_options(x,y,z):
    print("a):", x)
    print("b):", y)
    print("c):", z)

print("Hello! Welcome to my Quiz" "\n" "All Questions carries 10 marks each")
# To ask for input from the user
ans = input("Are you ready to play (yes/no): ")
a ="Note: wrtie answers! do not write option."

score = 0
total_questions = 4
correct_ans =["python", "steve jobs", "artificial intelligence", "bitcoin"]

if ans.lower() == "yes":
    print(a)

print("Question- What is the best Programming Language? ")
give_options("Python", "C", "Java" )
ans=input(">>>")

if ans.lower() == correct_ans[0]:
    score=score+1
    print("Correct")
else:
    print("Incorrect")

print(a)
print("Question- Who is the Founder of Apple Inc? ")
give_options("Mark Zuckerberg", "Warren Buffet", "Steve jobs")
ans = input(">>>")

if ans.lower() == correct_ans[1]:
    score=score+1
    print("Correct")
else:
    print("Incorrect")

print(a)
print("Question- What is more better among these? ")
give_options("Data Science", "Artificial Intelligence", "Digital Marketing")
ans = input(">>>")

if ans.lower() == correct_ans[2]:
    score=score+1
    print("Correct")
else:
    print("Incorrect")

print(a)
print("Question- What is the best Investment? ")
give_options("Share Capital", "Mutual Funds", "Bitcoin")
ans = input(">>>")

if ans.lower() == correct_ans[3]:
    score=score+1
    print("Correct")
else:
    print("Incorrect")

#Counting score
i = score*10
if i < 30:
    print("oops, your score is ",i,"/ 40 better luck next time.")
elif i ==30:
    print("wow! you scored ",i,"/ 40 you are quiet smart.")
else:
    print("Congratulations! it's a perfect ",i,"/ 40 you are Intelligent.")

#Output

Hello! Welcome to my Quiz
All Questions carries 10 marks each
Are you ready to play (yes/no): yes
Note: wrtie answers! do not write option.
Question- What is the best Programming Language?
a): Python
b): C
c): Java

Python
Correct


Note: wrtie answers! do not write option.
Question- Who is the Founder of Apple Inc?
a): Mark Zuckerberg
b): Warren Buffet
c): Steve jobs
Steve jobs
Correct


Note: wrtie answers! do not write option.
Question- What is more better among these?
a): Data Science
b): Artificial Intelligence
c): Digital Marketing
Artificial Intelligence
Correct


Note: wrtie answers! do not write option.
Question- What is the best Investment?
a): Share Capital
b): Mutual Funds
c): Bitcoin
Bitcoin
Correct


Congratulations! it’s a perfect 40 / 40 you are Intelligent.

Process finished with exit code 0

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1498

Leave a Reply