[Tutor] Chapter 3 Projects

Dave Angel davea at davea.name
Wed Apr 10 05:11:40 CEST 2013


On 04/09/2013 08:29 PM, ALAN GAULD wrote:
> Forwarded to group. Please use ReplyAll when responding to tutor posts.
>
>
>> ________________________________
>> From: Mariel Jane Sanchez <zac_vanessa1fan at yahoo.ca>
>> To: Alan Gauld <alan.gauld at btinternet.com>
>> Sent: Wednesday, 10 April 2013, 1:06
>> Subject: Re: [Tutor] Chapter 3 Projects
>>
>>
>>
>> Thank you so much, I finally figured out the 2nd project. I still have problems with 1 and 3 so I'll try to be more clear.
>>
>> It would help if you posted your code. It shouldn't be long and its much easier to see where you are getting confused if we can see the code!
> Chapter 3 Booklet PDF is attached
>>
>> Chapter 3
>> Project 1 on page 90 on the PDF
>> "1. Write a program that gets a score from the player and rates it on the following:
>> - Given a score between 0-999, the program should display the message, 'Nothing to brag about."
>> - Given a score between 1000-9999, the program should display the message, 'Good score.'
>> - Given a score over 9999, the program should display the message, 'Very impressive!"
>> - If the score is a negative number, the program should display the message, 'That is not a legal score!'"
>>
>> I'd do it like this
>
> score = raw_input('score? ')

That would need to be:
     score = int(raw_input('score? ')

> if score < 0: print 'That is not a legal score'
> elif score > 9999: print 'Very impressive'
> elif 9999 >= score >= 1000: print 'Good score.'
> elif  # student to complete...
>
>
>>
>> I tried using range as another tutor suggested which would make sense since it's dealing with ranges but I still get the same result as before. Can you explain how to do this step by step, if you don't mind?
>>
>> You can use range by substituting the elif lines above with:
>
> elif score in range(1000,10000): print 'Good score.'
>
> Project 3 (Guess My Number code on page 35)
>> "Modify the Guess My Number program from the chapter so that the player has only five guesses. If the player runs out of guesses, the program should end the game and display an appropriately chastising message"
>> For my case, I somehow, accidentally programmed it to have only 5 tries and also put a message that says " You ran out of tries," which I think is a good progress. However, on the last try; when I put my guess, hit enter and got the guess wrong, the message loops.
>>
>> I  showed you the structure for this last time.
> Without seeing your code I have no idea what you did wrong.
>
>
> When you first started on Python, how did you do this project so there's no loop at the end?
>>
>> I did not do those projects because I did not do the course that you are doing.
> I did not in fact do any courses, I just read the official documents and made
> up my own projects. So I can't tell you how I did it. I can only comment on how I might
> do it now.
>
> Alan Gauld
> Author of the Learn To Program website
>
> http://www.alan-g.me.uk/
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
DaveA


More information about the Tutor mailing list