intro

Python is an easy and powerful script language.

Let's start it with the "Hello world!"

print("Hello world!")
if

You don't use () for condition.

You can use a colon instead.

if condition==true:
  do(this)
else:
  do(that)
while

It is similar to if statement.

Colon and indentation matter.

while condition==true:
  keepDoing(this)
for

In Python, you can directly reference list items for for iteration, without defining an index variable.

for item in itemList:
  process(item)

If you want to use index, change the code like this.

for i in range(count):
  process(itemList[i])
function

Lastly, define a function like this.

You can remove the return statement if you don't need it.

def functionName(functionVariables):
  result = process(functionVariables)
  return result