request of information

2013-02-17 Thread leonardo selmi

> 
> 
> 
> 
>> gentlemen:
>> 
>> i am reading a book about python and now i am blocked, i can't store 
>> functions in modules: i have a mac and am using version 2.7.3, i have 
>> created a function and want to save it as a file using "idle", i have saved  
>> it with .py , when i try to import the module i get an error: traceback(most 
>> recent call last) file  
>> "", line 1, in  
>> import circle
>> file "circle.py", line 1
>> syntax error: invalid syntax
>> 
>> can you kindly help me?
>> thanks!
>> 
>> best regards
> 

-- 
http://mail.python.org/mailman/listinfo/python-list


request for help

2013-02-18 Thread leonardo selmi
pls i need help:

i have copied the following from a book and tried to make it work:

import math

def area(radius):
return math.pi * radius**2

def circumference(radius):
return 2 * math.pi * radius

i saved the above program from python shell into a file as "circle.py" . when i 
type "import circle" i get  error..


kind regards
-- 
http://mail.python.org/mailman/listinfo/python-list


need for help

2013-03-01 Thread leonardo selmi
hi guys

i typed the following program:

class ball:
def _init_(self, color, size, direction):
self.color = color
self.size = size
self.direction = direction

def _str_(self):
msg = 'hi, i am a ' + self.size + ' ' + self.color + 'ball!'
return msg

myball = ball('red', 'small', 'down')
print my ball

BUT I GOT THIS ERROR:

Traceback (most recent call last):
  File "/Users/leonardo/Documents/ball2.py", line 11, in 
myball = ball('red', 'small', 'down')
TypeError: this constructor takes no arguments

can you kindly tell me what is wrong?
thanks a lot!
-- 
http://mail.python.org/mailman/listinfo/python-list


book advice

2013-03-01 Thread leonardo selmi
hi

is there anyone can suggest me a good book to learn python? i read many but 
there is always something unclear or examples which give me errors.
how can I start building a sound educational background

thanks for any help 

best regards
-- 
http://mail.python.org/mailman/listinfo/python-list


problem with function

2013-03-21 Thread leonardo selmi
hi all,

i wrote the following code:

def find(word, letter):
index = 0
while index < len(word):
if word[index] == letter:
return index
index = index + 1
return -1

if i run the program i get this error: name 'word' is not defined.  how can i 
solve it?

thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


how does the % work?

2013-03-22 Thread leonardo selmi
hi guys

i wrote this example :

name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")

print """Ah, so your name is %s, your quest is %s, 
and your favorite color is %s."""  % (name, quest, color)

but i get this error:  Traceback (most recent call last):
  File "/Users/leonardo/print.py", line 5, in 
favourite color is %s.''') % (name, quest, color)
TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

how can i solve it?

thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


i need advice

2013-03-24 Thread leonardo selmi
dear python programmers,

i am focused on learning to program but i need help from all of you. i am a 
beginner but it is hard to find the right book or website to learn, i know that 
i have to do exercises but so far i found resources with gaps. i would be very 
grateful if you could give me suggestions. for example i have "think python" 
and "learning python the hard way", do you recommend them or are there better 
books?

thanks a lot and sorry for bugging you

best regards

leonardo
-- 
http://mail.python.org/mailman/listinfo/python-list


i need advice

2013-03-24 Thread leonardo selmi
dear python programmers,

i am focused on learning to program but i need help from all of you. i am a 
beginner but it is hard to find the right book or website to learn, i know that 
i have to do exercises but so far i found resources with gaps. i would be very 
grateful if you could give me suggestions. for example i have "think python" 
and "learning python the hard way", do you recommend them or are there better 
books?

thanks a lot and sorry for bugging you

best regards

leonardo
-- 
http://mail.python.org/mailman/listinfo/python-list


problem with sys import argv

2013-03-26 Thread leonardo selmi
hi python community,

i wrote the following programm:

from sys import argv

script, userName = argv
prompt = '> '

print 'hi %s, i am the %s script' % (userName, script)
print "i'd like to ask you a few questions."
print 'do you like me %s' % userName
likes = raw_input(prompt)

print "where do you live %s?" % userName
lives = raw_input(prompt)

print 'what kind of computer do you have?'
computer = raw_input(prompt)

print """
alright so you said %r about liking me.
you live in %r. not sure where that is.
and you have a %r computer. nice
""" % (likes, lives, computer)

and i got the following error:  Traceback (most recent call last):
File "/var/folders/89/84z7tw3d3rv39gny3n2p963mgn/T/pythonInTerm.GUF6PWCM", 
line 3, in 
  script, userName = argv
ValueError: need more than 1 value to unpack

what can i do?

thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


help needed

2013-04-08 Thread leonardo selmi
hello all,

i have typed the following program from the book "learn python the hard way":

from sys import argv

script, first, second, third = argv

print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third
then i get this error:

Traceback (most recent call last):
  File "/Users/leonardo/Documents/ex13.py", line 3, in 
script, first, second, third = argv
ValueError: need more than 1 value to unpack

in the book the author says that i should run the program like this:

$ python ex13.py first 2nd 3rd
The script is called: ex13.py
Your first variable is: first
Your second variable is: 2nd
Your third variable is: 3rd
but how can i do that?? what are the steps? where should i go?
thanks!

best regards
leonardo-- 
http://mail.python.org/mailman/listinfo/python-list


help..

2013-05-02 Thread leonardo selmi
i have also this program:

write a function called rental_car_costthat takes days as input and returns the 
cost for renting a car for said number of days. The cost must abide by the 
following conditions:
Every day you rent the car is $40.
If you rent the car for 3 or more days, you get $20 off your total.
If you rent the car for 7 or more days, you get $50 off your total. (This does 
not stack with the 20 dollars you get for renting the car over 3 days.)
so i wrote the following code:
def rental_car_cost(days):
cost = 40*days
if days >= 7:
return cost - 50
elif days >= 3 and days < 7:
return cost - 20
else:
return cost

but it seems not to be right cause the computer answers: Oops, try again! Did 
you create a function called rental_car_cost?

ii wrote also:

def rental_car_cost(days):
if days >= 7:
return (40*days) - 50
if days >= 3 and < 7:
return (40*days) - 20
else:
return (40*days)

they both work in python shell/idle but not in the exercise in 
"codecademy"..what do you think? is there a bug?

thanks!

kindest regards-- 
http://mail.python.org/mailman/listinfo/python-list


help to code...

2013-05-02 Thread leonardo selmi
dear python community,

i wrote the following program:

from datetime import datetime
now = datetime.now()
current_month = now.month
current_day = now.day
current_year = now.year
current_hour = now.hour
current_minute = now.minute
current_second = now.second
print str(current_month) + '/' + str(current_day) + '/' + str(current_year) +' 
'+ 
print str(current_hour) + str(current_minute) + str(current_second)

and i got this error:
Traceback (most recent call last):
  File "runner.py", line 125, in compilecode
  File "python", line 9
print str(current_month) + '/' + str(current_day) + '/' + str(current_year) 
+' '+

 ^
SyntaxError: invalid syntax

how can i write the last two lines correctly?

thanks!


-- 
http://mail.python.org/mailman/listinfo/python-list


learning python

2013-05-05 Thread leonardo selmi
hi guys

i need to find a good book to learn python with exercises and solutions, any 
suggestions?

thanks!

best regards

leonardo-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Help] learning python

2013-05-05 Thread leonardo selmi
thanks!



Il giorno 05/mag/2013, alle ore 18:58, Eric Brunson  ha 
scritto:

> On 05/05/2013 10:08 AM, leonardo selmi wrote:
>> hi guys
>> 
>> i need to find a good book to learn python with exercises and solutions, any 
>> suggestions?
>> 
>> thanks!
>> 
> 
> Leonardo,
> 
> There are several good online tutorials available, many listed here:  
> http://wiki.python.org/moin/BeginnersGuide
> 
> There is also the Python Tutorial written by the creator of Python here:  
> http://docs.python.org/2/tutorial/index.html
> 
> If you want a hands on approach with exercises, try Learn Python the Hard 
> Way:  http://learnpythonthehardway.org/
> 
> If you already have a background in programming I find Dive Into Python to be 
> an excellent introduction:  http://www.diveintopython.net/ as well as Think 
> Python: How to Think Like a Computer Scientist:  
> http://www.greenteapress.com/thinkpython/html/
> 
> If you want something you can hold in your hand and has paper pages, I can 
> recommend Learning Python by Mark Lutz:  
> http://shop.oreilly.com/product/9780596158071.do followed by The Python 
> Cookbook, by Alex Martelli and David Ascher:  
> http://shop.oreilly.com/product/9780596001674.do
> 
> The Massachusetts Institute of Technology uses Python to teach their 
> introduction to programming course which is available online (free) here:  
> http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/index.htm
> 
> I hope that helps.
> 
> Sincerely,
> e.
> 
> 

-- 
http://mail.python.org/mailman/listinfo/python-list