IntroductionSlide solved ✓
This lesson covers the basics of writing Python code.
Press the button to view the next slide.
The box below contains Python code that writes the number '1' to the screen.
You need to run the code to continue. Press the ' Run' button to run the code.
Change the code
We are now ready for your first challenge!
To continue, change the code so that it writes out
2 to the screen
1. Then run the code.
Good! You now know how to write a number to the screen. This is also called to print a number in programmer terminology.
Python programs can have more than one line. Most programs do.
Below is an example of a multi-line program.
print(1) print(2) print(3)
When you run the program below, Python will go through one line at a time, starting with the first one. It will run each line in turn.
Keep in mind that
Next you will learn how to do basic math, like adding and multiplying numbers.
Here is an example of code that adds two numbers:
Being able to do basic math is useful in many programs.
For example, you might want to write a program that converts between feet and centimeters, between Celsius and Fahrenheit, or between pounds and kilos. Such a program needs to use basic math.
Try adding numbers
To continue, change the code so that it calculates 1+1 and prints the result.
Try multiplying numbers
Good! Next, calculate two times two. The sign for multiplication is
Other math operators
The other math operators are just as self-explanatory as
- subtracts numbers and
/ divides numbers.