Skip to main content



Getting started with Python 2

For and Else for x in range(6): print(x) if x==2: break else: print("over") # this line will skip if last line exists Pass There cannot exist any blank within for and if else.

Getting started with Python 1

What’s new for me Do not need to declare variables indentation replaces curly braces to divide code blocks Grammar Assigning value to multiple variables x, y, z = 1, 2, "hello" Define a global variable in local function def myfunc(): global x x = "fantastic" Change the value of a global variable inside the function x = "declan" def myfunc(): global x x = "declan and jessica" New data type for me Sample Data Type x = 1j complex x = ["apple", "banana", "cherry"] list x = ("apple", "banana", "cherry") tuple x = range(6) range x = {"name" : "Bill", "age" : 63} dict x = {"apple", "banana", "cherry"} set x = frozenset({"apple", "banana", "cherry"}) frozenset x = True bool x = b"Hello" bytes x = bytearray(5) bytearray x = memoryview(bytes(5)) memoryview Specifying the data type x = dataType(value) Verify the data type x = 'declan' type(x) Random number import random x = random.