![]() |
"How to think like a computer scientist - Python"
Hello everyone I am glad that I found this forum by searching trough Google, hope you can help me out in my attempt to fully understand Python.
I have followed the guide "How To Think Like a Computerscientist - Python" and i've come to this place where I can't think of any creative ways to do what the exercise says: As an exercise, modify the program to fix this error. (It's the Jack, Kack, Lack, Mack, Nack, Ouack, Pack, and Quack Duckling exercise thing I am working on) http://www.ibiblio.org/obp/thinkCSpy/chap07.htm#3 I know that I could simply just make several of the example code in alphabetical order: :
prefixes = "JKLMNOPQ"like .. :
prefix1 = "JKLMN"But I am not sure if that is what is meant to be done in this guide? Maybe someone who have done this guide can answer this? Once again, I hope this forum will grow big and become the main spot for programming help.. |
You seem to have done exactly what is being asked of you in this exercise. Congrats and keep up the good work.
|
I'm not sure if they covered lists at that point, but you could also do:
:
prefix = ['J', 'K', 'L', 'M', 'N', 'Ou', 'P', 'Qu'] |
i would like to say to the poster cheers for the link i have been hunting down a fun python tutorial
|
Wow, I just got my own thoughts confirmed.. What a really nice place this is, with nice people and positive helping posts, thank you for your introduction :D
#4 (Berto) Yeah it's really nice, you should check out the other books at http://ibiblio.org/obp especially the Python ones.. Makes programming a little funnier. I can also recommend these books from a friend who is using them in a programming course he's running at the university he is employed. http://www.oreilly.com/catalog/python2/index.html http://www.oreilly.com/catalog/lpython2/index.html Gotta love Python :D .. http://home.no/dezza/python Prolly the youngest python programmer in the world ;) .. I know this is found on O'Reilly somewhere but I couldn't find the destination and I was to lazy to look for it, just kept it for saving. #2 (peace_of_mind) Thank you, and what a nice signature of yours, makes a new programmer welcome into the scene. #3 (Moldz) Thanks, worked out really fine! I think it have been mentioned, i've read the book (not fully though) before and I know that there is such a thing as lists :) Like you can do things like this: :
print prefix[0]+" what a nice functiona!"By the way, how do I get "return" to print when running the code as script? I know that you can see the + and - in the interpreter, but can you make it print the true/false statement? I need it in this case: :
import string |
| All times are GMT -5. The time now is 6:07 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC