|
13th May 2011, 14:40 | #1 |
|
Python coding
So I am doing CompSci 111 at UA at the moment as general ed and we use Pyhthon to code programs. I used to write basic code when I was like 12 or so on the C64 and could write silly little games.
Looking at python, it seems very similar but without the numbers to refer to when using GOTO and functions like that. Question is, has anyone used Python here much and have been able to create some pretty nifty applications?
__________________
asghasdhoaidhoqhdoqjwod;asdadas |
13th May 2011, 14:56 | #2 |
|
I'm currently studying python at UC. From what I can tell its not as powerful as something like c but is far easier to learn and a lot quicker to use. I'm currently trying to create a game dodgem
Your right, it doesn't have the GOTO command but the functions work much the same way and are much easier to debug than GOTO. |
13th May 2011, 20:14 | #3 |
HENCE WHY FOREVER ALONE
|
I like Python. It has arbitrary precision integers!
A lot of cool projects use Python, so while you can't write a device driver with it, it's still pretty powerful in its own way.
__________________
Finger rolling rhythm, ride the horse one hand... |
13th May 2011, 20:31 | #4 |
|
I'm just new to it and the only programming I have done is BASIC years ago so I'm still trying to get my head around certain things.
For example: GOTO was the best thing ever for me when I used basic. Say if I create a 3d6 random generator to roll 3 6 sided die, then at the end of the random program I want to say "Press Enter to roll again" i could have said goto line x to keep looping the code. But with python because I don't have that I wonder if I need to use the while command. So if i write: enter = "y" while(enter = "y"): ( random die number code here ) enter = input("Roll again? y or n") Would that code cause my loop to keep going until another character was entered? Once I figure out how to replace my understanding of GOTO then I can start having tons of fun writing shit. Will also need to learn how to draw shapes with it too. Also, can you convert your python code into an executable?
__________________
asghasdhoaidhoqhdoqjwod;asdadas |
13th May 2011, 20:58 | #5 |
|
You need to put the second 'enter' bit inside the while loop, otherwise you'll end up with an infinite loop rolling dice
Code:
__________________
"Nothing is so smiple that it can't be screwed up." |
13th May 2011, 21:00 | #6 |
|
Oh, and bookmark http://docs.python.org
__________________
"Nothing is so smiple that it can't be screwed up." |
13th May 2011, 23:17 | #7 |
|
Chur. I got hat die roll going nicely. Works a treat.
__________________
asghasdhoaidhoqhdoqjwod;asdadas |
14th May 2011, 12:14 | #8 |
|
I found this very useful when I started programming
http://en.wikibooks.org/wiki/Non-Pro...for_Python_2.6 |
14th May 2011, 20:19 | #9 |
|
I'll use this thread to ask questions now that I find it impossible to find using google.
If I allocate certain values or strings to variables, is there there a way to random pull a variable and print it? For example, I might have a deck of cards mapped out to variables. And I want the random command to pull any card from that list I have made. What would the command be?
__________________
asghasdhoaidhoqhdoqjwod;asdadas |
14th May 2011, 20:36 | #10 |
HENCE WHY FOREVER ALONE
|
Sounds like you want to have a list of variables (eg names of cards) and define a function to randomly pick a number (which is the list index eg 0 to 51) and return the element of the list referenced by that number.
http://docs.python.org/tutorial/introduction.html#lists http://docs.python.org/tutorial/cont...ning-functions
__________________
Finger rolling rhythm, ride the horse one hand... |
16th May 2011, 13:16 | #11 | |
|
Quote:
So rather than resetting to a point in your code & running through it again to execute common code, you compartmentalise that code within a function or an object method & call that function/method where needed. http://en.wikipedia.org/wiki/Goto#Alternatives Have a read just so you're not coding like it's 1970.
__________________
Your a homo. |
|