[Tutor] some problem, please help me

Alan Gauld alan.gauld at yahoo.co.uk
Thu May 28 19:47:48 EDT 2020


On 28/05/2020 19:44, Markzer wrote:


You haven't asked a question?
If you expect someone to take the time to respond please take the time
to provide information.

What do you expect to happen?
What does happen?
If you get an error message post it - all of it.
Which version of python are you using?
On which OS?

Finally never expect anyone else to run your code.
It would be extremely foolish to do so without studying it
first, since it could contain any kind of dangerous code.
And who has the time to read random bits of code from the internet?

Also this is a text based list so attachments usually get stripped off,
its better to put your code into the email body. I've done that for you
below....



####################################
from pythonclass import Question
question_prompts =[
    "What is the name of the creator of the program?\n(a) Joaquin\n(b)
Gabriel\n(c) Leonardo\n(d) All others are incorrect\n\n",
    "What is the favorite color of the creator?\n(a) Blue\n(b) Gray\n(c)
Yellow\n(d) White\n\n",
    "How old is the creator?\n(a) 15 (b) 16 (c)13 (d) 14\n\n"
]
questions = [
    Question(question_prompts[0], "c"),
    Question(question_prompts[1], "a"),
    Question(question_prompts[2], "d")
]



def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
    if answer == question.answer:
        score += 1
    print("You got " + str(score) + "/" + str(len(questions)) + " Correct")


run_test(questions)
#################################

Bear in mind that we are not on your class. we have no idea
what pythonclass is or what Question looks like or
does - formats my hard drive in the background perhaps?

BTW. You might want to think about the indentation level of
your if statement....


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list