Recap
In the first lesson, we learned that:
- We can print to the console using the
print()
function. - Text is written in quotes
""
, numbers are not. - We have the following arithmetic operations:
+
(addition),-
(subtraction),*
(multiplication),/
(division),%
(integer remainder). - Comments are created by inserting
#
in a line, and everything in that line after this character is ignored by the computer. - We store information in variables that we will use later in the program.
- We can create, overwrite, and use a variable:
age = 21 # creation
age = 22 # overwrite
print(age) # use (prints 22)
- We can concatenate text using the
+
sign:
name = "John"
print("My name is " + name + ".") # prints: My name is John.
- To print a number and text together in one
print()
function, we must convert the number to text using thestr()
function.
print("I am " + str(48) + " years old.")
Congratulations on completing the first Python lesson! In the next lesson, we will learn how to use conditionals for variable program behavior!
Instructions
When you are ready, proceed to the next lesson!
Start programming for free
10/10