Re: [Tutor] What books do you recommend?

2009-12-11 Thread Becky Mcquilling
Thanks, Alan.  It is fun and on many levels I welcome the challenge.

I won't continue to divert this thread from good books, but I will continue
to look for more and more tutorials and will post it  The more the more
merrier...

Becky

On Thu, Dec 10, 2009 at 2:24 PM, Alan Gauld wrote:

>
> "Becky Mcquilling"  wrote
>
>  Good points.  I guess being as new as I am I'm not always sure of the
>> obvious way to do something or what I think is right,
>>
>
> One thing to remember is that it is always subjective.
> There is no such thing as an absolute "right way to do it"
> There are too many factors and virtually all solutions reflect
> a set of compromises by the designer
>
>
>  But others may not find this useful.  I admit that learning this stuff
>> does
>> not come particularly easy to me,
>>
>
> Its not easy to learn a new way of thinking and thats essentially
> what programming is.  Some people will always find it easier
> and some harder but it is fundamentally a challenging activity
> for everyone - and that's part of what makes it fun!
>
>
> --
> 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
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Still making Cribbage game, NEED HELP Please

2009-12-11 Thread Lie Ryan

On 12/10/2009 1:24 PM, Christopher schueler wrote:

I  am still working on my cribbage game..

if you want rules or an outline of the rules/project information,
it is HERE ->
http://jongarvin.com/cawthra/files/ics3u/cribbage_project..pdf


I have attached a copy of what i have so far..
i have built a deck with 52 cards AND made a dictionary containing each
card and its value such as Jacks and kings worth a value of 10.

I was wondering if people could give me ways to finish this project
WITHOUT CLASSES because we havent learnd them yet OR could somebody
right their own program for this cribbage game so i can compare or get
ideas from your coding.

This also contains my PSUEDOCODE if anybody wants to review how i did
things or what certain things do




First, black box evaluation, I'll just write things that comes to mind 
before seeing the code:


- disallow empty names

- prompts for cards: you may want to allow user to type "3D" instead of
  the card's number (the prompt "what CARD..." teases me to type the
  "card" I want even if the prompt says "1 -  6").

- minor: invalid input ideally shouldn't crash the program (though many
  teacher considers this outside marking criteria, since it's not
  possible to draw the line).

- super-minor: try to minimize Speling erorrs (Instruction, comments,
  etc). Use spell-checkers if necessary.

- minor: stylistic issues: See other command line programs to get a
  "feel" of how prompt statements should look like.



General suggestion:
- See in the project description, there is a stage 1,2,3, and for
  each stage there are sub-stages? Make at least one function from each
  of those sub-stages. It'll make your program flow clearer.

- If you and all your teammates never played cribbage before, you'd
  better seek other resources for the rule. The rule given in the
  project description leaves a *lot* of thing unexplained, it is simply
  impossible to write a game just from that alone.

- From reading the game rules described in the project description,
  apparently the game is divided into six separate rounds. Make six
  functions, each representing one round, and you main program will
  simply look like this:

def play_game():
pre_game()
round_deal()
round_cut()
round_pegging()
round_show()
round_crib()
round_end()

- DRY: Don't Repeat Yourself. If you see two blocks of code
  that looks similar, try to make them into a function (or loops, or
  whatever seems appropriate to reduce similarity):
  e.g. this two blocks looks disturbingly similar

for X in range(0,6):
Y = randint(0,ele)
draw = Deck[Y]
P1hand.append(draw)once
Deck.pop(Y)
ele -= 1
for X2 in range (0,6):
Y1 = randint(0,ele)
draw2 = Deck[Y1]
P2hand.append(draw2)
Deck.pop(Y1)
ele -= 1

- try to minimize variables, especially global variables (don't confuse
  between variables and constants). e.g. ele is just the number of card
  in the deck, you can use len(Deck) instead.

- It depends on you, but I think it will be easier to random.shuffle
  the deck before the play and just Deck.pop() each time we need to
  draw a new card rather than randomly picking from a sorted deck. It
  also looks more like a real card game, where the dealer shuffled the
  deck before game and just pulled the top of the decks when dealing.

- if you're using python 2.6 or above, take a look at itertools.product
  if you're using python 2.7 or python 3, take a look at the new
  combinatoric generators functions in itertools

Specific suggestion:
- try rewriting this using random.choice()

Top = randint(0,39)
Topcard = Deck[Top]

- try to turn these two into one function only

def GetPlayer1():
print
Player1 = str(raw_input("Player 1's name "))
return Player1
def GetPlayer2():
print
Player2 = str(raw_input("Player 2's name "))
return Player2

Crystal Ball:
- my guess why your teacher disallowed using class and object is
  because his plan for your next project is to turn the cribbage game
  to use classes. So, make sure you choose designs where it will be
  easy to convert to objects-oriented at later date. This way, you'll
  have to know both procedural and OOP while putting OOP at much better
  light than if he only teach OOP.

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


[Tutor] typerror

2009-12-11 Thread Roshan S

class Student:
print"We have a new student "
def __init__(self,name='',credit=0,grade=0,quality=0):
self.name=name
self.credit=credit
self.grade=grade
self.quality=quality


def inputstudent(self):
self.name=raw_input("Enter student Name ")
self.credit=input("What da credit hours ")
self.grade=input("What da grade ")

def quality(self):
self.quality=self.credit*self.grade
print"Quality Points: ",self.quality

def average(self):
quality()
gpa=self.quality/self.credit
print"Grade point average: "+self.grade
if gpa == 4: print "Grade: A"
elif gpa == 3: print "Grade: B"
elif gpa == 2: print "Grade: C"
elif gpa == 1: print "Grade: D"

def outputstudent(self):
"Name: "+self.name

#main
#create new student
stud1=Student()

#run teh method
stud1.inputstudent()
stud1.outputstudent()
stud1.quality()
stud1.average()


RUN





We have a new student
Enter student Name r
What da credit hours 3
What da grade 5
Traceback (most recent call last):
  File "C:\Users\Roshan\Desktop\no3.py", line 38, in 
stud1.quality()
TypeError: 'int' object is not callable





PYTHON version 2.6.3, windows 7
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What books do you recommend?

2009-12-11 Thread Jeff Johnson

Becky Mcquilling wrote:
Thanks, Alan.  It is fun and on many levels I welcome the challenge.  

I won't continue to divert this thread from good books, but I will 
continue to look for more and more tutorials and will post it  The more 
the more merrier...


Becky 


I read through all the posts to make sure someone didn't already 
recommend this, but The Python Phrasebook is a great one.  It has 
working code for a whole bunch of things like sending emails and reading 
websites just to name two.  You can type them in and run them.  It 
allowed me to quickly learn and appreciate Python.


http://www.amazon.com/Python-Phrasebook-Brad-Dayley/dp/0672329107

I am not suggesting Amazon, it was just the first link I found.  I see 
it in bookstores like Borders.


--
Jeff

Jeff Johnson
j...@dcsoftware.com
Phoenix Python User Group - sunpigg...@googlegroups.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] More on unit testing - tests for external data...

2009-12-11 Thread Kent Johnson
On Thu, Dec 10, 2009 at 11:19 PM, Modulok  wrote:

> It seems like there are a lot of people on this list interested in
> getting more familiar with unit testing, but not a whole lot of
> non-trivial, python-specific examples being passed around.

> Case studies/tutorials anyone?

Unit testing has become common, accepted practice in open source
projects so real-world examples abound.

Python itself has extensive unit tests. To a large extent they
actually define the language and the libraries - Jython and IronPython
use the CPython test suite to validate their implementations. Download
the Python source to get a copy of the tests.

The Python unit tests largely predate the unittest module so they are
not necessarily good examples of unittest.

I suggest you pick an open source Python project that you use or like
and look at its test suite.

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


Re: [Tutor] typerror

2009-12-11 Thread spir
"Roshan S"  dixit:

> class Student:
>  print"We have a new student "
>  def __init__(self,name='',credit=0,grade=0,quality=0):
>  self.name=name
>  self.credit=credit
>  self.grade=grade
>  self.quality=quality
> 
> 
>  def inputstudent(self):
>  self.name=raw_input("Enter student Name ")
>  self.credit=input("What da credit hours ")
>  self.grade=input("What da grade ")
> 
>  def quality(self):
>  self.quality=self.credit*self.grade
>  print"Quality Points: ",self.quality
> 
>  def average(self):
>  quality()
>  gpa=self.quality/self.credit
>  print"Grade point average: "+self.grade
>  if gpa == 4: print "Grade: A"
>  elif gpa == 3: print "Grade: B"
>  elif gpa == 2: print "Grade: C"
>  elif gpa == 1: print "Grade: D"
> 
>  def outputstudent(self):
>  "Name: "+self.name
> 
> #main
> #create new student
> stud1=Student()
> 
> #run teh method
> stud1.inputstudent()
> stud1.outputstudent()
> stud1.quality()
> stud1.average()
> 
> 
> RUN
> 
> 
> >>>
> We have a new student
> Enter student Name r
> What da credit hours 3
> What da grade 5
> Traceback (most recent call last):
>File "C:\Users\Roshan\Desktop\no3.py", line 38, in 
>  stud1.quality()
> TypeError: 'int' object is not callable
> >>>
> 
> 
> PYTHON version 2.6.3, windows 7

You've got 2 attributes called 'quality'. One is a method that is defined on 
the class, the other a piece of data later defined on the student object itself 
at init time. The second one will override the method, hiding it. Python does 
not make a difference between behaviour attributes (methods) and state ones 
(data), so you cannot have a method called like a piece of data.
Anyway, in your case the method is an *action* that sets and prints out an 
attribute, so its name should reflect this fact.

Denis



la vita e estrany

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


Re: [Tutor] typerror

2009-12-11 Thread Dave Angel

Roshan S wrote:
class 
Student:

print"We have a new student "
def __init__(self,name='',credit=0,grade=0,quality=0):
self.name=name
self.credit=credit
self.grade=grade
self.quality=quality


def inputstudent(self):
self.name=raw_input("Enter student Name ")
self.credit=input("What da credit hours ")
self.grade=input("What da grade ")

def quality(self):
self.quality=self.credit*self.grade
print"Quality Points: ",self.quality

def average(self):
quality()
gpa=self.quality/self.credit
print"Grade point average: "+self.grade
if gpa == 4: print "Grade: A"
elif gpa == 3: print "Grade: B"
elif gpa == 2: print "Grade: C"
elif gpa == 1: print "Grade: D"

def outputstudent(self):
"Name: "+self.name

#main
#create new student
stud1=Student()

#run teh method
stud1.inputstudent()
stud1.outputstudent()
stud1.quality()
stud1.average()


RUN





We have a new student
Enter student Name r
What da credit hours 3
What da grade 5
Traceback (most recent call last):
  File "C:\Users\Roshan\Desktop\no3.py", line 38, in 
stud1.quality()
TypeError: 'int' object is not callable





PYTHON version 2.6.3, windows 7


In your Student class, you're using attribute quality for two very 
different purposes.  You have a method by that name, and you have an 
instance variable by that name.  You need to call one of them something 
else, probably the instance variable.  Don't forget to change all the 
references to it, both in __init__() and in the method quality().



HTH

DaveA

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


Re: [Tutor] typerror

2009-12-11 Thread Roshan S

On Fri, 11 Dec 2009 19:12:32 +0400, Dave Angel  wrote:


Roshan S wrote:
class  
Student:

print"We have a new student "
def __init__(self,name='',credit=0,grade=0,quality=0):
self.name=name
self.credit=credit
self.grade=grade
self.quality=quality


def inputstudent(self):
self.name=raw_input("Enter student Name ")
self.credit=input("What da credit hours ")
self.grade=input("What da grade ")

def quality(self):
self.quality=self.credit*self.grade
print"Quality Points: ",self.quality

def average(self):
quality()
gpa=self.quality/self.credit
print"Grade point average: "+self.grade
if gpa == 4: print "Grade: A"
elif gpa == 3: print "Grade: B"
elif gpa == 2: print "Grade: C"
elif gpa == 1: print "Grade: D"

def outputstudent(self):
"Name: "+self.name

#main
#create new student
stud1=Student()

#run teh method
stud1.inputstudent()
stud1.outputstudent()
stud1.quality()
stud1.average()


RUN





We have a new student
Enter student Name r
What da credit hours 3
What da grade 5
Traceback (most recent call last):
  File "C:\Users\Roshan\Desktop\no3.py", line 38, in 
stud1.quality()
TypeError: 'int' object is not callable





PYTHON version 2.6.3, windows 7


In your Student class, you're using attribute quality for two very  
different purposes.  You have a method by that name, and you have an  
instance variable by that name.  You need to call one of them something  
else, probably the instance variable.  Don't forget to change all the  
references to it, both in __init__() and in the method quality().



HTH

DaveA



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


[Tutor] Software Development Courses

2009-12-11 Thread Elaine Haight
Foothill College is offering two courses of interest to web application
software developers: Ajax and Python. These 11-week courses are held from
January through March. The Ajax class is entirely online, and the Python
class meets Thursday evenings at the Middlefield campus in Palo Alto.

 “Application Software Development with Ajax” is a course designed for
students who are already familiar with some type of programming, and have
introductory knowledge of JavaScript and html. For more information, go to:
http://www.foothill.edu/schedule/schedule.php
and choose Department: “COIN”, quarter: “Winter 2010”, and course number
“71”.

“Introduction to Python Programming” meets Thursday evenings and is also
designed for students who are familiar with some type of programming. The
instructor is Marilyn Davis. For more information or to register, go to:

http://www.foothill.edu/schedule/schedule.php
and choose Department: “CIS”, quarter: “Winter 2010”, and course number
“68K”.

If you would like to sign up for a class, please register beforehand by
going to:
http://www.foothill.fhda.edu/reg/index.php
If you do not register ahead of time, the class you want may be cancelled!

If you have questions, you can contact:
h a i g h t E l a i n e AT f o o t h i l l . e d u
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What books do you recommend?

2009-12-11 Thread Che M



> I won't continue to divert this thread from good books, but I will continue 
> to look 
> for more and more tutorials and will post it  The more the more merrier...


> Becky 

Just on that topic of tutorials, have you seen www.ShowMeDo.com?  
They have right now 516 screencast tutorials related (directly or indirectly)
to Python.  This way you can watch a video and usually hear a person
describing what they are doing and why.  Oftentimes, videos are organized 
into a series on a particular topic, like GUI programming, databases, etc.
It's a different way to learn, and I find it a great service to the Python
(and other programming or computer use) community.

Che
  
_
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/171222984/direct/01/___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Learn Python

2009-12-11 Thread Grigor Kolev
Hi
I'm trying to learn python but I have difficulties with classes.
If someone has a code that shows the basic concepts and relationships in
the classes, please send it to me.
I will be happy if code possess very much comments
-- 
Grigor Kolev 

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


Re: [Tutor] What books do you recommend?

2009-12-11 Thread Alan Gauld


"Che M"  wrote


Just on that topic of tutorials, have you seen www.ShowMeDo.com?


I'll echo this. I found the ShowMeDo site to be an excellent source, 
especially

for learning the more hands-on type skills like using Eclipse/PyDev etc.


--
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


Re: [Tutor] Learn Python

2009-12-11 Thread Alan Gauld


"Grigor Kolev"  wrote 


I'm trying to learn python but I have difficulties with classes.
If someone has a code that shows the basic concepts and relationships in
the classes, please send it to me.


Most tutorials should show that.

You can try the OOP topic in mine if you like, also the Case study topic
has a worked example

--
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