CSCA08H3 Final: Python Introductory Examples
Document Summary
Python introductory examples: define a variable and give it a value. Examples: time = 3 num = 30 + 10 num = time + 2. When defining a variable you must have the variable name on the left hand side, then an equal sign, then an expression: write an expression, you can try this out in the python shell. 30 + 10 num + 20. 2 time + num. An expression is a phrase of code that python evaluates to produce a value: write a statement. At this point in the course you have only seen assignment statements. Examples: num = num * 2 time = 3. # statement that doubles the value of num. # statement that assigns the value 3 to time. Python statements are always commands to do something (never statements of fact, or questions).