I am new to phyton

Recommended Answers

All 7 Replies

All of us have been new once, it is not sin. Just take one step at time and test your code.

for the quiz i want
questions
answers
number of questions to ask
score
number of questioned asked so far
can you help me out? im confused

Good luck! We can help anybody who shows proper effort and posts spesific question after proving effort.

well so far i got this

print  ("Welcome to my quiz!")
begin = (input("would you like to begin?: "))
if begin =="yes":

    q1 = (input("Is Steve Jobs is the founder of Apple?"))
    if q1 == "true" or q1 == "True":
        print ("well done! you got it right!")
    if q1 == "False" or q1 == "false":
        print ("wrong, try again")
else :
    print ("Thanks for trying my quiz! Goodbye")

This is how I would fix it (I used beginning lines to get it run also in Python2)

# make input equal to Python3 style input even in Python2
try:
    input = raw_input
except:
    pass

print("Welcome to my quiz!")
questions = (("Is Steve Jobs the founder of Apple?", 'yes'),
             ("Is this stupid program?", 'no'))
for q, right in questions:    
    if input(q).lower() == right:
        print("Well done! You got it right!")
    else:
        print("You got it wrong this time!")

how do i add number of questions to ask

i want to make sure that people can ask how many question the want to answer in my quiz. how can i do that?

# make input equal to Python3 style input even in Python2
try:
    input = raw_input
except:
    pass
def questions ():
    global questionlist
    print =("how many question do you want to answer")
    while questioncount < 4:


print("Welcome to my yes or no quiz!")
questions = (("Denis Glover wrote the poem The Magpies ", 'yes'),
             ("God Save the King was New Zealand’s national anthem up to and including during WWII  ", 'yes'),
             ("Kiri Te Kanawa is a Wellington-born opera singer  ", 'no'),
             ("Phar Lap was a New Zealand born horse who won the Melbourne Cup  ", 'yes'),
             ("Queen Victoria was the reigning monarch of England at the time of the Treaty  ", 'yes'),
             ("Split Enz are a well-known rock group from Australia who became very famous in New Zealand during the 80s  ", 'no'),
             ("Te Rauparaha is credited with intellectual property rights of Kamate!  ", 'yes'),
             ("The All Blacks are New Zealands top rugby team ", 'yes'),
             ("The Treaty of Waitangi was signed at Parliament  ", 'no'),
             ("The Treaty of Waitangi was signed in 1901 ", 'no'),
             ("Aotearoa commonly means Land of the Long White Cloud   ", 'yes'))


for q, right in questions:
    if input(q).lower() == right:
        print("Well done! You got it right!")
    else:
        print("You got it wrong this time!")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.