[Edu-sig] simple guessing games

Daniel Ajoy da.ajoy at gmail.com
Mon Sep 11 06:16:36 CEST 2006


On 9 Sep 2006 at 0:28, edu-sig-request at python.org wrote:

> From: Dan Crosta <dcrosta at sccs.swarthmore.edu>
> Subject: Re: [Edu-sig] The fate of raw_input() in Python 3000
> 
> When I think back to when I was learning to program in 9th grade (I'm 
> not a professional software devel) I know that it was really exciting to
> be able to twiddle with the computer for a bit, then call my mom over 
> and have her work with my program -- simple guessing games, ...
> 
> But even
> though it did, it would not have been as exciting to sit my mom down 
> with it and let her play around, and I wouldn't want to have to explain 
> to her (even now with a nearly infinitely more sophisticated 
> understanding of computers and programming than I did in my first 
> months) what a function is, how to interact with it, what arguments are,
> etc.

The following is in Logo.

I put the this in a text file:
=======================
to i.guess :number
if :number < :initial.guess [
 print [your guess is less than my number.]
]
if :number > :initial.guess [
 print [your guess is greater than my number.]
]
if :number = :initial.guess [
 print [You got it! To try again type: restart]
]
end

to restart
print [Guess a number between 0 and 99]
print [Type: i.guess number]
make "initial.guess random 100
end

restart
=======================

Then when I clic on the icon of that file I get:

(In Logo the prompt is "?")


Guess a number between 0 and 99
Type: i.guess number

? i.guess 50
your guess is less than my number.

? i.guess 70
your guess is less than my number.

? i.guess 80
your guess is less than my number.

? i.guess 90
your guess is greater than my number.

? i.guess 85
your guess is greater than my number.

? i.guess 83
your guess is less than my number.

? i.guess 84
You got it! To try again type: restart

? restart

Guess a number between 0 and 99
Type: i.guess number


----

I'm passing arguments to functions. I'm not using "raw_input", I'm 
using the prompt. AND I'm not teaching mon what a function is. :)


Daniel



More information about the Edu-sig mailing list