- To print and concatenate strings, type the command using the + symbol.
- To print multiple times, use the asterisk with a number as the multiplicand.
- Variables are fundamental and used in just about every language. Variables are defined using lower case letters.
- Variables can be assigned, sticking with the basics, Integers, Floats, Strings, or Booleans.
- Integers are whole numbers without a decimal, Floats are floating-point numbers with a decimal, Strings are text surrounded by single quote characters, and Booleans are binary set representations of True or False states.
The “if statement” is used for conditional executions.
Suppose we want to print a message only if a motor is a DC motor. We would create the if statement to determine if the motor is a DC motor using a Boolean, True or False condition, for example, we will set a Boolean variable called “is_DC” to True and then use this in the if statement.
- The next code line will be executed if the if statement condition is True, if not it will print what is commanded after the else statement.
- If we set the Boolean “is_DC” to False, the second print() command, after the else statement will be executed.