Once you have Python installed, you can move on to working with the language and learning the basics. To get you started, we’re going to discuss several projects you can attempt, even if you have no prior programming experience.
Keep in mind, you must have Python already installed to participate.
1) Hello World
> python3 #to call upon Python on MAC OS X use this command, for Windows use "python"
Python 3.5.1 (default, Jan 14 2016, 06:54:11)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World")
>>> print("My name is Bob")
My name is Bob
The text you see after the # symbol is called a comment. Comments do not appear at runtime, and are instead meant for the developers who will be working with the code. The comment we left above provides instructions for adding your name to the message. More often than not, comments will provide labels or quick descriptions for a snippet of code, so you can easily identify what a particular section is for.
2) Performing Calculations
>>> 7 + 2
Notice how the interpreter automatically answers the equation and spits out the result?
3) Creating Your First String
>>> "Hello there " + "my name is " + "Bob"
'Hello there my name is Bob'
>>> "Bob" * 4
Pretty cool, right?
4) Return the Length of a Phrase or Word
>>> players = ['bryan', 'john', 'chris']
5) Storing Variables
>>> movie = "Cinderella"
Sweet! No more crazy robots or androids! Just Cinderella!
You can store just about anything inside a variable, including numbers, equations, and more.
>>> 9 < 1
>>> 6 > 2 * 4
>>> 3 == 3
>>> 5 != 2
In addition, if you want to check whether or not two values are unequal you can use an exclamation mark followed by an equal sign like so: “!=”
The World is Your Oyster
Recommended Python Training
Course: Python 3 For Beginners
Over 15 hours of video content with guided instruction for beginners. Learn how to create real world applications and master the basics.