Teaching Home HTML Introduction HTMLtags HTMLdoc Element Tree HTML Element Attributes CSS Introduction CSS Basics JavaScript Introduction JavaScript Basics Python Introduction Python Basics Pesky Pixie Home (separate website)

Python Basics

Basic Python Commands

Output Command

print("Hello, World!")

Input Command

name = input("Enter Name")

Selection

if name == "Joe Bloggs":

print("Hello Joe Bloggs")

elif name == "Mr Smith":

print ("Hello Mr Smith")
else:
print("you're not Joe Bloggs or Mr Smith")

Iteration

"Definite" iteration refers to count controlled loops. That is loops that loop a "definite" number of times. See the example below.

for i in range (10):

print("Hello World")

"Indefinite" iteration refers to condition controlled loops. That is loops that loop an indefinite number of times until a condition is met.

name = " "

while name != "Joe Bloggs":

print("your not who we're looking for")
name = input("Enter Name")

if name == "Joe Bloggs":

print("Welcome Mr Bloggs, we've been expecting you")

Try these code examples out for yourself in the interactive development environment (IDLE) below