[Tutor] Chapter 3 Projects

Alan Gauld alan.gauld at btinternet.com
Mon Mar 25 01:36:37 CET 2013


On 24/03/13 23:38, Mariel Jane Sanchez wrote:

> thing especially when I put 1000000, my typed phrase "Good Score" shows
> up when "Very Impressive" is the appropriate phrase to go with that
> score. And when I put in a negative score it says the same thing instead
> of saying it's an invalid score. How do I put those ranges so that the
> phrases match with it?

Bear in mind that we have no idea what projects you are talking about. 
You might have the PDF at school but we don't even have that so you need 
to explain in detail what you are talking about.

When you say "input the ranges" what do you mean? Are you trying to read 
the range from a user? Or do you want to produce a range in your code? 
And do you need all of the numbers in the range? Or are you only testing 
against the max/min of the range? I can't tell from your description.

> the second project is about flipping a coin 100 times and I have to show
> how many heads and tails where randomly flipped. My problem is that, I
> do get a random number for each sides of the coin but the number is
> either below or above 100. What am I doing wrong?

Do you know how to repeat an action a known number of times?
If so the number of tails is the total minus the number of heads.
Can you collect or count the number of heads?

> Lastly, the third project is doing the same thing as one of the demo
> codes.

Without sight of the demo codes that means nothing to us.

>  have to make a guessing game that only gives the player 5
> tries. I just don't understand how to end the loop when the user used up
> their 5 chances.

Do you know about while loops?

number_of_tries = 0
while number_of_tries < 5:
     do your loop stuff here
     number_of_tries = number_of_tries +1

> When I run it and tried to guess the number, it's still
> the same as the demo code where I can guess as long as I want. What do I
> put to only have 5 chances? Also,

> how do I match the 2 phrases? For
> example, the player guessed the number within 5 attempts, the phrase
> that is congratulating the player should pop out and vise versa when the
> player exceeded his chances.

Do you know about if statements?
Also you can combine tests in your while loop using boolean (or logical) 
operators like and, or and not.
Does that help?

hth
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list