[Python] Tutorial #1 (Hello World)

Buddy_mybb_import10515

Active Member
Reputation
0
Python is a great language capable of being used as a programming language and a scripting language. It's completely cross platform and can be used for many purposes.

To start this off we'll begin to learn about how simple a lot of it is.
To do this we'll make a simple "Hello World!" program.

There are many ways to do this. My favorite being...
Code:
print("Hello World!")

In Python print must always be lower case unless it's a string. The method of putting it in parenthesis is smarter for this tutorial because it can be used as an intro to both Python 2 and 3. Python 3 has a few differences. The most obvious being the fact that print is used as a function.

In Python 2 we can solve the Hello World with a different solution because this version doesn't use print as a function, thus there is no need for parenthesis.
Code:
 print 'Hello World'

There was a little confusion...
In Python 2 you can do it either way.
Code:
print 'Hello World'
print("Hello World")

In python 3 you can ONLY do it this way.
Code:
print("Hello World!")

-Thanks for reading. There will be more soon. :D
 
Nice guide. I always forget the difference between Python2 and 3....
 
Different syntax.
Not everything is different, but enough to make them too different to share one tutorial unless it's something as simple as hello world.

Don't fret though. I don't know the differences either. D:
Only that print is a function in 3. It can be used as a function in python2, but only as a function in python 3.
 
Ok, python 3 looks easier by far. I don't know why but it looks much more simple. My opinion.
 
Zennywop said:
Ok, python 3 looks easier by far. I don't know why but it looks much more simple. My opinion.

They both look the same.

Python 3 is worse. Less support, smaller library, and way more bugs.
Also anything you can do in Python 3 you can do in python 2.
 
kk. I might try getting back into python scripting. I havn't been doing much as i have been very busy, plus learning Basc java so i can script for the new API for rsbot.... We could both learn java and make a script lol.
 
Back
Top