Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Week 1: Python basics and PRINT()

BASICS:

 Running Python Shell (IDLE)

Integrated Development and Learning Environment (IDLE) and it is an integrated development


environment, or IDE, that helps us with writing Python programs.

 Saving code
 Opening code
o Recent files
 Running saved code ( F5 )

PRINT():

1. What it is used for


a. output
b. debugging
2. Tricky Printing
o ‘ and “
o Escape characters ( \ )
o Multiple Lines ( \n )
3. Comments ( # )
Week 2: VARIABLES

A variable is just a fancy name for a tag, or a way to keep track of information. It’s just like many tags we
see in life:

 Some people wear name tags so we know who they are.


 Nutrition labels on food are tags. They tell us all kinds of information, like how many calories the
food has, the grams of sugar it contains, or the list of ingredients used.
 Tags on clothing provide tons of information, including the size, designer, price, and sometimes
even the identity of the person who inspected it.

When we code, we use variables to hold pieces of information for us.

Strings:

Ex.

reader = "Casey"

print(reader)

Integers:

num = 3

print(num)

Things to know:

1. Variables cant start with a number


2. Variables cannot contain spaces
3. Variables are case sensitive
4. Variable names should be as descriptive as possible

Variable styling:

camelCase: the first word of a variable name is not capitalized, but every other word after is. (Example:
numberOfCookies)

PascalCase: every word in a variable name is capitalized. (Example: NumberOfCookies)


FANCY PRINTING:

Formatted string literals! AKA F-STRINGS

When you use the f character before a string, the computer knows that you are about to create an f-
string. Once it knows this, it starts looking for the opening and closing quotes of the string like normal,
but when it comes across some braces ({}), it says, “Oh, here’s a part of the string Human wants me to
replace.

EXAMPLE

food = “Sushi”

f"I like {food}"

EXAMPLE

feeling = “happy”

print(f"I'm so {feeling} to be learning how to code in Python!")

Multiline Formatted string literals

We create a variable called multiline_sentence. We then assign that variable to our actual multi-line
sentence, which is typed out exactly as we want it on its different lines. You’ll notice that, instead of our
normal quotes, we use another special type of escape character for multi-line strings—these are called
triple quotes. All that means is that we are using a pair of three double quotes or a pair of three single
quotes (remember, don’t mix and match!) as the starting and ending quotes for our multi-line string.
This tells the computer to print out what we put in between these triple quotes exactly the way we have
it. After that, we use our handy f-string to print it!

EXAMPLE

multiline_sentence = """

Here is

a sentence

on many

different lines.

"""

print(f"{multiline_sentence}")

You might also like