Python has similar syntax to that of many familiar programming languages, particularly Javascript. Here's the Euler rule program in Python 3:
If you're getting ready for Python 3, you can use the print function. This tutorial will use parentheses in print statements for compatibility with Python 3.
Variables are assigned with the "=" operator. In Python, variables are dynamically typed, which means that the interpreter only checks type correctness when the code is run:
Dynamic typing has its shortfalls, one of which being that your editor can't easily check for errors:
Comments are delimited with two symbols; # for those on a single line and ''' (three single or double quotes) for comments that stretch across multiple lines:
A function is an indented block of code that may accept some parameters/arguments (separated by commas) and optionally returns an object. Functions are declared with the "def" keyword and called with their name and a list of arguments in parentheses:
Functions do not have to require parameters or return anything:
Like any other Python object, functions can be assigned to variables and used later:
Python uses whitespace indenting, which means that there are no braces or end statements:
An Easter egg for the Java and C programmers out there: