Re: [Tutor] command error

2010-02-17 Thread pk

Dnia 17-02-2010 o 00:41:21 Shurui Liu (Aaron Liu) shuru...@gmail.com
napisał(a):

But I have tried, it doesn't work on my workstation, i don't know why. I  
run

it on my python software, python 3.0.


The script is written in Python 2. Try rewriting it, mostly by changing
the number formatting, function syntax and function names. Or simply
install a Python 2.x interpreter.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] command error

2010-02-16 Thread Sander Sweers
On 16 February 2010 21:32, Shurui Liu (Aaron Liu) shuru...@gmail.com wrote:
 Here is a program I wrote, I don't know why I cannot exit when I tried 10
 times? Hope somebody can help me. Thank you!

 while (guess != the_number):
     if (guess  the_number):
     print (Lower...)
     print (You were wrong, try again, tries, times left.\n)
     else:
     print (Higher...)
     print (You were wrong, try again, tries, times left.\n)

     guess = int(raw_input(Take a guess: ))
     tries -= 1

This will loop untill guess == the_number with no other way out.
Meaning unless the number is guessed it will end up in an infinite
loop. You will have to figure out how to *break* out ot the while loop
when tries == 0.

Greets
Sander
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] command error

2010-02-16 Thread pk

Dnia 16-02-2010 o 21:55:47 Sander Sweers sander.swe...@gmail.com
napisał(a):

On 16 February 2010 21:32, Shurui Liu (Aaron Liu) shuru...@gmail.com  
wrote:
Here is a program I wrote, I don't know why I cannot exit when I tried  
10

times? Hope somebody can help me. Thank you!

while (guess != the_number):
if (guess  the_number):
print (Lower...)
print (You were wrong, try again, tries, times left.\n)
else:
print (Higher...)
print (You were wrong, try again, tries, times left.\n)

guess = int(raw_input(Take a guess: ))
tries -= 1


This will loop untill guess == the_number with no other way out.
Meaning unless the number is guessed it will end up in an infinite
loop. You will have to figure out how to *break* out ot the while loop
when tries == 0.


Hello,

Shurui Liu try adding, as Sander Sweers has written, the break keyword to
your script.

In the meantime I've written an alternative version of the program that
does the same thing. I'm a complete beginner (Python is my first
programming language) and a hobbyist so I thought I could take up the
challenge and try to solve the problem in my spare time.

The script seems to work, I've tested it. List members, if there are any
mistakes or things that can be done better, please let me know.

Here's the body of the script:

#!/usr/bin/python
# -*- coding: utf-16 -*-

right_guess = 7
number_of_guesses = 10

print Guess the number. You have ten guesses

for an_attempt in range(1, 11):
  answer = int(raw_input(Guess the number: ))
  if answer == right_guess:
  print That's the correct number! Congrats pal, I mean my dear
teacher ;)
  break
  else:
  number_of_guesses = number_of_guesses - 1
  if number_of_guesses == 0:
  print You have no more guesses.\n\t\tGAME OVER
  break
  print That's not the right number. Choose again, you have %i  
more

guesses % number_of_guesses


Regards,
Piotr

guess_my_number.py
Description: Binary data
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] command error help

2010-02-14 Thread Shurui Liu (Aaron Liu)
SyntaxError: EOL while scanning single-quoted string.





2010/2/14 Shurui Liu (Aaron Liu) shuru...@gmail.com

 Here is a program I need to run in putty.exe, but there is an error in it.
 I cannot find out. When I ran this program, it mentions that the error is in
 red line.It shows that SyntaxError: EOL while scanning single-quoted
 string.  Would you please help me? Thank you!


 # Useless Trivia

 #
 # Gets personal information from the user and then
 # prints true, but useless information about him or her

 name = raw_input(Hi.  What's your name? )

 age = raw_input(And how old are you? )


 age = int(age)

 weight = raw_input(Okay, last question.  How many pounds do you weigh? )
 weight = int(weight)

 print \nIf poet ee cummings were to email you, he'd address you as, 
 name.lower()


 ee_mad = name.upper()
 print But if ee were mad, he'd call you, ee_mad

 dog_years = age / 7
 print \nDid you know that you're just, dog_years, in dog years?



 seconds = age * 365 * 24 * 60 * 60
 print But you're also over, seconds, seconds old.

 called = name * 5
 print \nIf a small child were trying to get your attention,  \


   your name would become:
 print called

 moon_weight = weight / 6.0
 print \nDid you know that on the moon you would weigh only, moon_weight, 
 pounds?

 sun_weight = weight * 27.1

 print But on the sun, you'd weigh, sun_weight, (but, ah... not for long).

 raw_input(\n\nPress the enter key to exit.)



 --
 Shurui Liu (Aaron Liu)
 Computer Science  Engineering Technology
 University of Toledo



 --
 Shurui Liu (Aaron Liu)
 Computer Science  Engineering Technology
 University of Toledo




-- 
Shurui Liu (Aaron Liu)
Computer Science  Engineering Technology
University of Toledo
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] command error help

2010-02-14 Thread Alan Gauld


Shurui Liu (Aaron Liu) shuru...@gmail.com wrote


SyntaxError: EOL while scanning single-quoted string.


Yes, that sounds about right.
But it doesn't add much. Can you print the entifre error
message not just that single line? Or

Here is a program I need to run in putty.exe, but there is an error in 
it.
I cannot find out. When I ran this program, it mentions that the error 
is in

red line.


How are you running the code in putty.
I don't get any red lines in my terminal...
It suggests you might be using some other tool or IDE perhaps?

Since I can't see any single quoted strings in your code we
can't begin to guess what line the error pertains to.
It might for example be one of the apostraphes thats causing the error?


name = raw_input(Hi.  What's your name? )
age = raw_input(And how old are you? )
age = int(age)

weight = raw_input(Okay, last question.  How many pounds do you weigh? 
)

weight = int(weight)

print \nIf poet ee cummings were to email you, he'd address you as, 
name.lower()

ee_mad = name.upper()
print But if ee were mad, he'd call you, ee_mad

dog_years = age / 7
print \nDid you know that you're just, dog_years, in dog years?
seconds = age * 365 * 24 * 60 * 60
print But you're also over, seconds, seconds old.

called = name * 5
print \nIf a small child were trying to get your attention,  \

  your name would become:
print called

moon_weight = weight / 6.0
print \nDid you know that on the moon you would weigh only, 
moon_weight, pounds?


sun_weight = weight * 27.1
print But on the sun, you'd weigh, sun_weight, (but, ah... not for 
long).


raw_input(\n\nPress the enter key to exit.)



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



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor