Jump to content

[Detailed Guide] Beginning Python 2.6

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
40 replies to this topic

#1
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
This is an old guide I made about a year or so ago and today I have decided to clean it up a bit and make it better. This guide should go according to Python 2.6. I would update this guide but, I have not used Python since (Anyone wanting to alter this guide and make it compatible for 3.0 is welcome. Send me a PM with the changes and I will include credits).


Alright, so you came here for either two things; A) Your looking to become a programmer, or B) Your taking some unwanted programming classes and you need to learn something quick. Either way, I am going to show you the basic fundamentals between some different programming languages and how they work. So, in a way this would be your basic introduction to programming theory as well. I am sure you have spent a lot of time trying to read guides and coding books that didn't work out as planned. Maybe every time you got a book you would get sick of reading it and you started to think, "I'll never learn to code", or maybe you have motivation but you just don't understand any of that "gibberish" that is described in those books. Well, I am here to kind of clear that up for you and make it easier for you to understand the basics so you can attempt to read from more advanced books. Now, that we have that out of the way, lets continue on to what you need.



[Requirements & Recommendations]


  • [Requirements]
  • A Programming Compiler (C++, Python, Visual Basic, etc)

  • [Recommendations]
  • Read this guide carefully. Read it again if you don't understand it.
  • Have a reference guide when coding, like a programming book of your choice.
  • Visit some if not all of the links that I have posted in this guide.
I recommend that you read some if not all the contents that are attached to this guide, they hold vast amounts of information and are really good to read. I have read them all and I definitely recommend it people looking to get inspiration. You should start with Python to get the feeling of how coding works and to really understand how it all works. If you want to become a game programmer then you should quickly move on to C++ when you are ready. Now if you plan on reading everything I told you to read then Kudos to you, if not I really recommend that you do.

If you do not like reading, you should stop now or just grind through it because their is a lot of reading associated with this guide. I have always said, "Failure's do not become successor's because they do not apply the tools around them. - Donovan Simon". Let's move on to the contents of this guide.


[Contents]


Quote

Folder: Become a Programmer

Quote



- Linux Related

This folder has a lot of information about Unix and Linux. If you are interested in either of them, then you should start their. These are some good things to know when wanting to become a programmer.

- HTML Related

This folder has a few topics about HTML. I have not read this folder yet but, I know they have some good free tutorials and some information that could be useful for HTML beginners.

- Software Related

This is just about software. The only guide in it at the moment is, "Software Releases". It explains what you should do when you release new software and what you should think about when releasing new patches or versions for that software.

- Cultural and Informational

This folder has some information about the programming community. Some terms that you will find a lot of programmers use and things that the programming community like and dislike. This is what motivated me in becoming a programmer and I think it will help you as well. I recommend you read everything in this folder. Once you do you will have some information about the programing culture and community
. You might even gain some more respect from people around the community for taking the time out to read into it and know more about it. Knowing programming is one thing but, knowing how it work, where it came from, and the history is really good to know.

- Learning to Program

This folder has a web page that talks all about programming. The Python documentation is there for you to read all about python. Please Note: Some of the contents may not be fully published.



[Python Basics]

Lets start off with simple calculations. If you would like you can open python 2.6 and begin. If you learn these three things you should be able to open Python and begin basic coding without any worries or confusion. You might not be able to code your program to do everything you want it to do but, you will be able to do some basic stuff.



  • Defining a Variable
Lets say you wanted to add the variable health in your game. Then, you also implement a ring that adds +5 to the players health. You would have to define your variable health with a numerical value that associates it with the users health points. In this case we will use the 100. You then create a variable ring which is equal to the variable of health + 5. Usually people will define all there items and variables in the beginning. Which is why you would normally write the story line of a game first before coding it.


Health = 100

Ring = health + 5


print "Welcome to 'THE GAME' your health is", Health

If you loaded that script in the Python 2.6 console, it would look something like this;
[COLOR=Black]

Welcome to 'THE GAME' your health is 100


>>>

[/COLOR]


The chevron (>>>) symbol indicates that you are at the end of scripts simulations. You can make continuous loops, or menus that do not end a game unless otherwise authorized by the user as well. So, those are the basics to defining a variable. Variables are used in games to define how many bag slots are left, what time it is on the game, and various other things.

[User Input]

This is where you learn how to implement the action or interacting parts of your program. This is key when making a game, the more interaction the user has with the game the more entertainment he or she will have while playing. In this example we ask the user a question and store the users input in a data stream known as raw_input.


Health = 100

Ring = health + 5


print "Welcome to 'THE GAME' your health is", Health

Name = raw_input("\nWhat is your name?: ")

print "\nNice to meet you", Name



With that out of the way, lets continue to another example below.


Balance = 1000

print "Welcome to 'The Bank System' you balance is", Balance

Withdraw = input("Withdraw Amount: ")

Balance -= Withdraw

print "\nYour current balance is now: $", Balance

Withdraw = input("Withdraw Amount: ")

Balance -= Withdraw



[If & Else Statements]

Here is an example of the If and Else statement, the If and Else statements can be used for allowing multiple decisions or actions to be made, checking, sending, or receiving information, and plenty of other useful tasks. Here is an example of these very statements at work.


Balance = 1000

Withdraw = 0

print "Welcome to 'The Bank System' you balance is", Balance

Withdraw = input("Withdraw Amount: ")

if Balance == 0:

    print "\nYour out of money!"

if Withdraw > Balance:

    print "\nYou do not have that much!"

    Withdraw = input("Withdraw Amount: ")

Balance -= Withdraw

print "\nYour current balance is now,", Balance



Well, thank you for taking the time out to read my programming guide but, most of all you should be thanking yourself for taking that first step. I have provided some extra resources and information below that can further assist you with anything you may need as a beginner.

[B][CODING TIPS]

[/B]

Name Spaces: Name spaces or line spaces are often used to create a new  line within code. In order to do this, simply add, "\n" right before the  sentence you want to be on the next line.


Printing Messages: Printing message or sending output to the user is  also simple. Just use this code, "print "My Message!"


Displaying Variables in Messages: Displaying or defining variables in  messages is also quite simple, just experiment with the example code  below and you will get the hang of it.


Example 1: print "Welcome to the bank, your balance is: ", pBalance

Example 2: print "Welcome ", pName ", to Cosco."

Example 3: print "Welcome ", pName sName = Cosco ", to ", sName "."


These are just a few examples on how this works.


[COLOR=Black][SIZE=2]Variable1 > Variable2: If  Variable1 is greater than Variable2

I.E: Quarter > Dime

[/SIZE][/COLOR] 

[SIZE=2][COLOR=Black]Variable1 -= Variable2: I do not know  how to make this into a definition but, this will make it so you do not  have to add another Variable2 and rename it to variable3 when doing a  calculation. Like shown above.[/COLOR][/SIZE] [SIZE=2][COLOR=Black]


Variable1 = Value: Defines the value of a variable.

I.E: Variable1 = 1[/COLOR][/SIZE] [SIZE=2][COLOR=Black]


Variable1 = Variable2 - Variable3: [/COLOR][/SIZE][SIZE=2][COLOR=Black]A variable that is equal to a negative variable equation.[/COLOR][/SIZE][SIZE=2][COLOR=Black]

I.E: Broke = Person - Money


Variable1 = Variable2 + Variable3: A variable that is equal to an additional variable equation.[/COLOR][/SIZE]

I.E: Rich = Person + Money


Remember: code is case sensitive, so if anything does not match you will  have errors in your code.



[Downloads and Resources]

Gzipped source tar ball (2.6) (sig)
Bzipped source tar ball (2.6) (sig)
Windows x86 MSI Installer (2.6) (sig)
Windows AMD64 MSI Installer (2.6) (sig)
Max Installer disc image (2.6) (sig)


Excellent Python Guide:
Here

Attached Files


Edited by Roger, 28 May 2011 - 02:20 PM.

Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#2
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
I know this is not perfect code. I just wanted to point out some basic things for users. Do not always follow this code by heart. Later on in coding you will learn easier ways to code things properly. This is just something you can learn with as a beginner.
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#3
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Nice tutorial, and I liked how you added other information to be downloaded! I don't know Python, though :D

+rep ;)
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#4
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
Thanks for the reputation guys. Please make sure to visit Python Programming - Wikibooks, collection of open-content textbooks as stated in the guide:) Very good resource for python.

Credits to Steve.L for linking me this site:)
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#5
Steve.L

Steve.L

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 444 posts
Some of the articles on that site aren't even written yet lol. But a lot of the content is fairly decent and easy to understand, and backed by some good examples.

#6
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Great work mate! Fairly detailed and I will be downloading that file as soon as I +rep you :D

I can see you will be noticed by the CC community REALLY quickly!
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation

Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!


#7
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
Thank you guys:) This is my goal to make some very good guides on CC and to become a very good fluent programmer in at least 5 languages:D
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#8
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Time, effort and commitment will get you to your goal :D
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation

Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!


#9
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
I think I have the time, I know I have the commitment.. But I hope people do not think I am going overboard on posting. So I am going to tone it down a bit lol.. So I am going to keep on average about 5 - 10 posts a day.
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ

#10
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Overboard on posting?

CodeCall began in 2006. Since then, the total number of posts made on the entire forum is around 89%.

Over 9% of that entire total consists of my posts. And I only joined a few months ago.

That is overboard.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#11
Steve.L

Steve.L

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 444 posts
By 89%, Xav means 89,000.
By a few months, Xav means 7.

Silly Xav. :D

#12
Donovan

Donovan

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 798 posts
hehe:) I think the posting has gone to his head:P

Well, Thanks Xav I feel a bit better now. Maybe in a few years once some of the other members leave me and you will be here with 20,000+ posts hanging around waiting for more posts to comment on lol.. Sooner or later we will be posting back on each others haha:P
Posted Image
+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ