Printing in Python is a very important first skill to learn. Printing will display text in the console.
print shows that we will be printing something
( ) whatever is inside the parentheses will be printed
“ “ shows that we will be printing words / a string
Hello World! are the words that will be printed in the console
print("Hello World!")
>>> Hello World!
Comments are also super important. Comments can be used to take notes while programming, don't run a specific line, and of course, write comments!
You can write a Single Line Comment by using a #. Or, if you want your comment to go through several lines, you can write a Several Line Comment by adding ””” to the top and bottom of your comments. When the computer reads code, it will do everything until it sees a comment symbol, then jump to the next thing.
print("Hello World!") # Prints "Hello World!" into the console! This is unrelated to the actual code
>>> Hello World!
print("Hello World!")
"""
Several lice comments
Go here!
Also unrelated to how the code runs
"""
>>> Hello World!
Variables are a keystone component of programming. Just like algebra, Python also uses variables.
Let’s say you have a game you made, and you have 250,000+ lines of code. What if you got a lawsuit, and had to change the color of the ......text? Instead of going through every line where you have the text color, you can set one variable to hold that color.
You can set variables as integers or strings. Variables are read right to left. What is on the right of the equal sign is going to be stored. What is on the left of the equal sign is where it is going to be stored. Let’s say you wanted to set x to 1 + 4. You can do x = 1 + 4. It will read what is on the right, so 1 + 4 = 5, therefore it will store 5 inside of x. You can also do math with variables. If both variables are an integer, you can do any sort of math with them.
Key Words:
Integer: Any whole number. i.e 1, 100, 88
Float: Any number with a decimal. i.e 1.0, 10.223, 99.95
String: Any characters stored in a variable. i.e. "Hello!", "⭐👀", "(⊙o⊙)"
x = 2
y = 3
print(x + y)
>>> 5
x = 2 + 6
y = 1 + 1
print(x * y)
>>> 16
name = "Jackson"
print(name)
>>> Jackson
Make a program that prints your name on one line, then prints your favorite number on another line. Make sure your code is organized with comments. Your favorite number has to be stored as a variable, but you can normally print your name.