+91 81900 98289

Python Glossary

This Python Glossary lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.

A few words are worth pinning down. An argument is the value you pass. A parameter is the name in the function. An exception is an error object. A module is a file you can import.

Iterable means you can loop over it. Mutable means the object can be changed in place.

Example 1: Start here

A list is mutable. A tuple and a string are not.

terms = {"parameter": "name in the function", "argument": "value you pass"} # a dictionary; each key has one value print(terms["argument"])

Example 2: Store the idea in a name

Python Glossary begins with a value you can point at. The name topic holds that text.

topic = "Python Glossary" # text print(topic)

Example 3: Check it with if

An if chooses one branch. Change the score and run it again to see the other message.

score = 18 # a whole number if score >= 80: # run the indented lines only when this is true print("Pass") else: # runs when the test above was false print("Try again")

Example 4: Repeat with a loop

A for loop runs the indented line once per step. The numbers 1, 2, and 3 are printed on their own lines.

for step in range(1, 4): # repeat once per number; range stops before the last print("Step", step) # a comma prints each value, with a space between
A list is mutable. A tuple and a string are not.
Call Now 81900 98289