Python Tutorial, Beginners | 1 | 09-25-2012, 11:24 PM
#1
![[Image: attachment-0001.png]](http://mail.python.org/pipermail/pythonmac-sig/attachments/20060321/9f67b59a/attachment-0001.png)
![[Image: tqpbe.png]](http://i.imgur.com/tqpbe.png)
Hello, and welcome AF,
Today I'll be going through some of the basics in Python, I'll also be showing where you can download the right Python version for your specific OS.
(I would recommend Python 2.7.3, since it's supported by more applications. You can read more on www.python.org)
I would really recommend Python as one of their first languages if you are about to start. It's very easy and powerful, and I think you will learn a lot. Not only coding maybe, but logical thinking.
First: Download Python at: http://www.python.org/download/
Secondary, install Python, its pretty easy I think you'll manage.
![Wink Wink](https://sinister.ly/images/smilies/set/wink.png)
After that, please open up Python 'IDLE (Python GUI)' and it will look something like this:
(Without the coding)
![[Image: python+learning.png]](http://3.bp.blogspot.com/_VRoF3tMuDkw/S876Gkrm18I/AAAAAAAAAkk/qXnrsJYlobk/s1600/python+learning.png)
So, now you've pretty much started up and you're ready to start coding!
You are now coding in the Python Shell, where you can create simple programs.
Start by writing: "print Hello World" and press enter. Python will print out the line "Hello World" for you.
It will look something like the following:
![[Image: tqpbe.png]](http://i.imgur.com/tqpbe.png)
As you see, i wrote:
print "Hello World, SLUAST"
and it print "Hello World, SLUAST"
Pretty basic right? But, its a good thing to know
![Wink Wink](https://sinister.ly/images/smilies/set/wink.png)
There are some things you have to change to get some things work with the print statement. Such as, if you write it like this:
print 5
It will show only: 5
Right?
And then Python will print the 5, which is a number and can be added, multiplied, divided, and etc... with other NUMBERS. So, if you're trying to the equation: 22+3
Just write this: 22+3
and press enter. It will basically just print out what the sum of the two numbers added together.
Well, so if you are for an instance making a program to add strings and numbers. You might write something like this:
print "im elite,"+1337
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
print "im elite"+1337
TypeError: cannot concatenate 'str' and 'int' objects
Well, you'll get that error. The part that begins with "File" says which file, and where in the file the error is located. Then it will show the code, and a little brief description on the error. This is an error where you cant add strings to integers (only numbers). And that's impossible right? Or? To solve this you can do one simple thing, by turning the user you want to use into a variable. One example is:
X = 1337
and press enter.
then write in following:
print "im elite"+X
You'll get the same error there,
![Wink Wink](https://sinister.ly/images/smilies/set/wink.png)
Well, you haven't changed the variable X's number (1337) into a string by doing this you have to add these " ' ' ", like this:
X = '1337'
print "im elite "+X
will result in:
im elite 1337
So thats basically a very short tutorial for today, I hope to post one more tomorrow, on Friday, and hopefully a few more on the weekend. Then I'll be discussing some more friendly Python shells, third party IDLES, etc. I will also be concluding how to make your own little quiz, working with lists, more with variables and much much more!
Thanks for reading, please comment if you liked the tutorial and please check back in a few days. Have a nice day everyone!
![Biggrin Biggrin](https://sinister.ly/images/smilies/set/biggrin.png)
(This post was last modified: 09-25-2012, 11:43 PM by Dismas.)