When using the equals sign operator, = is an assignment operator, while == is a relational operator.
The OR operator returns TRUE if either condition is TRUE, else it will return FALSE.
The AND operator only returns TRUE if both conditions if TRUE, else it will return FALSE.
Any non-zero number in Python is interpreted as TRUE.
IF statements are structured with a header followed by an indented body. This structure is called a block.
There are two types of loops:
For loops
While loops
Input the correct keywords:
for char in "alpha":
print(char)
A FOR loop iterates over a set range of intervals whereas a WHILE loop iterates only as long as some condition is TRUE.
There are two ways of controlling loops:
BREAK
CONTINUE
BREAK exits the loop body immediately.
CONTINUE skips ahead to the next iteration in a loop.
A list is a python data structure that contains a sequential collection of zero or more Python data objects.
Lists are mutable, meaning that values of an item in the list are modifiable.
The IN operator asks whether an item is in a sequence.
Tuples are immutable, meaning that values of an item in the list are unable to be modified.
A tuple is an ordered sequence of values of any data type.
Using tuples enable functions to return more than one value.
Strings are usually indicated with single or double quotation marks around it.
In order to concatenate two strings, we use the + operator to combine the two strings together.
In order to repeat a string, the * operator is used to repeat the string by the number of times inputted.
Indexing a string or a list is done by using square brackets and the value's index. E.g. schools [ 0 ] to locate the first school.
Slicing a string or a list is done by using square brackets with a colon splitting the lower bound and upper bound. E.g. schools [ 0:5 ] to extract the first 5 schools.
When slicing, the lower bound is inclusive while the upper bound is exclusive.
Format specifiers allows control of the fill character, alignment, sign, width, precision, and type of data when it's substituted for the replacement field.
The format of a specifer is <width>.<precision><type> , where width specifies the number of letters/digits allowed, precision is the number of decimal places, and type indicates the data type.
A dictionary contains a key that is mapped to a value, also known as a key-value pair/item.
A list is an ordered sequence of objects, whereas a dictionary is an unordered set.