Discord Server Red Security Twitter Donation to Red Security Red Security Youtube Channel Red Security Tumblr Profile
Login or Register to Hide ads and Accessing all features on the forum

Tutorial 

Python beginner's project (Quiz Game)

2 Replies, 1039 Views

[Image: Create-a-Quiz-Game-with-Python.png?fit=1280%2C720&ssl=1]

Code:
# text based Quiz Game

# making a variable to store total marks
marks = 0

# Greet the user if he/she wants to play
answer = input("Do you want to play? ")
if  answer.lower() == 'yes':
    print("Let's Start the game")
else:
    print("Ok come back next time!")
    exit()
# Asking the first question
answer = input("Who invented the BALLPOINT PEN? ")

# lower() coverts the each alphabet
# of string into lower case
if  answer.lower() == 'biro brothers':
    print("Correct")
# if user give correct answer increment marks by 1
    marks += 1
else:
    print("Incorrect")

answer = input("What J. B. Dunlop invented? ")
if  answer.lower() == 'pneumatic rubber tire':
    print("Correct")
    marks += 1
else:
    print("Incorrect")

answer = input("What Galileo invented? ")
if  answer.lower() == 'thermometer':
    print("Correct")
    marks += 1
else:
    print("Incorrect")

answer = input("This English inventor is known as the 'Father of Computing.' ")
if  answer.lower() == 'charles babbage':
    print("Correct")
    marks += 1
else:
    print("Incorrect")

answer = input("For whom high heeled shoes were invented? ")
if  answer.lower() == 'King Louis':
    print("Correct")
    marks += 1
else:
    print("Incorrect")

# Decisions based on marks
if marks < 2:
    print("Try again")
# elif short for if else
elif marks <= 3:
    print("You tried better")

elif marks > 3:
    print("Good job you did it Congrats")

# Printing the percentage of correct answers
print("You got " + str((marks/5) * 100) + "% marks")

   
"Keep Good care of your Health
 Allah Hafiz and Good Bye Till the next post"
"Keep Learning and Keep exploring"
Love me like you do Heart
(This post was last modified: 04-27-2022, 12:23 AM by Covid-19.)
I think, if we could have an image of the game processed would be nice and make mkre sence
Rs
* Thankful to Allah *
Kurdy
(04-26-2022, 07:41 PM)Mr.Kurd Wrote: I think, if we could have an image of the game processed would be nice and make mkre sence
Ok I'll edit it. Thanks for your suggestion.
Love me like you do Heart

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tutorial Doubly Linked List in Python Covid-19 0 2,248 07-30-2022, 09:15 PM
Last Post: Covid-19
  Tutorial Linked List in Python Covid-19 2 2,638 07-30-2022, 08:25 PM
Last Post: Covid-19
  Tutorial File Handling in Python Covid-19 2 2,673 06-16-2022, 06:17 PM
Last Post: Covid-19
  Tutorial Exceptions in Python Covid-19 0 1,843 06-08-2022, 09:19 PM
Last Post: Covid-19
  Free Automate the boring stuff with Python Covid-19 0 1,607 06-07-2022, 06:58 PM
Last Post: Covid-19
  Tutorial Turtle in Python Covid-19 0 1,841 06-02-2022, 10:14 PM
Last Post: Covid-19
  Tutorial Python 3.5: Class Methods Covid-19 0 1,792 05-29-2022, 01:07 PM
Last Post: Covid-19
  Tutorial Python 3.2: Inheritance in Python Covid-19 2 2,833 05-27-2022, 06:47 PM
Last Post: Covid-19
  Tutorial Python 3.4: Encapsulation and Abstraction Covid-19 0 1,825 05-27-2022, 06:45 PM
Last Post: Covid-19
  Tutorial Python 3.3: Operator Overloading Covid-19 2 2,827 05-26-2022, 08:50 PM
Last Post: Covid-19



Users browsing this thread: 1 Guest(s)