Preview lessons, content and tests

Computer Science & Programming solved. All in one platform.

1. To trial the platform and take tests, please take a few seconds to SIGN UP and SET UP FREE.

2. Searching for something specific? See our text overview of all tests. Scroll right for levels, and lists.

3. Student and Teacher User Guides |  Schemes of Work |   Real Teacher use Videos |


Join 36000+ teachers and students using TTIO.

Variables

Variables are containers for storing data values. Unlike other programming languages, Python has no command for declaring a variable. A variable is created the moment you first assign a value to it.

x = 5
y = "TestandTrack"
print(x)
print(y)

Constants

A constant is a type of variable whose value cannot be changed. It is helpful to think of constants as containers that hold information which cannot be changed later. Convention in python suggests you use CAPITAL letters when declaring a constant.

PI = 3.14
GRAVITY = 9.8

Assignment and Comparison - the difference

x = 2 (this stores the value 2 in the variable x)

if x==2: (this checks to see if the value of x is equal to 2)

Learning/Teaching Presentation

Data Types

In programming, data type is an important concept. Variables can store data of different types, and different types can do different things. Python has the following data types built-in by default, in these categories:

Text: str (example: "John")

Numeric Types: int, float, complex

Sequence Types: list, tuple, range

Mapping Type: dict

Boolean Type: bool 

 

www.teachyourselfpython.com