×
Home Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10 Lesson 11 Lesson 12 Lesson 13 Lesson 14

Lesson 1: Print()

In Python, we use the print() function to display information.


Learning Target

I can use the print() function to display a message.

Tasks:

  • Write a Python statement to print your name and your favorite emoji.

Lesson 1.1: Strings and Integers

Strings and integers are data types that can be added to variables within Python code. A variable is a container that stores a value, like a string of text, a number, or other data types.

Strings of text go inside quotation marks and can be used in various ways. An integer is a numeric data type that represents a whole number.

Variable names can contain letters, numbers, and underscores, but not symbols or spaces. Python’s standard naming convention is all lowercase characters with underscores replacing spaces.


Purpose

Understand how to use strings and integers in Visual Studio using Python.

Tasks:

Lesson: Floats and Booleans

Floats and booleans are additional data types in Python. While integers represent whole numbers, floats (short for "floating point numbers") are numbers with decimals, like 3.14 or 0.75. The boolean (or bool) data type only has two values: True or False. These are often used to control game logic, such as whether a player is alive or has won.

Learning Target

I can use floats and booleans in basic operations and identify their data types in Python.

Tasks:

Project: Analyze Data Types


Purpose

By completing this project, you will strengthen your understanding of Python data types and improve your ability to identify them correctly in code.

Steps for Completion

  1. Open the 114-analyze.py file from your Domain 1 Student folder.
  2. Review the five print statements in the file.
  3. Identify the data type used in each statement and record your answers below:

Reflect

Think about what you just explored. Understanding data types is a key part of writing error-free, logical code.

Lesson 2: Variables

Variables store information in Python. You create a variable by giving it a name and assigning it a value using the = sign.

Learning Target

I can store and reuse data in variables.

name = "Ava"
print("Hi " + name)
  

Tasks:

  • Create a variable for your favorite movie or show. Then print a message using it.

Lesson: Data Type Conversion

Lesson: Indexing

Lesson 3: Numbers and Math

Python can do math just like a calculator. Use + to add, - to subtract, * to multiply, and / to divide.

Learning Target

I can use variables to perform math operations.

a = 5
b = 3
print(a + b)
  

Tasks:

  • Create two variables with numbers and print their product

Slicing

Data Structures

  1. Strings are a type of data structure because they are collections of characters.
  2. Match each code example to the correct data structure:

Lesson 4: Lists and Their Operations

A list is a collection of items stored in a specific order. Instead of creating a separate variable for each value, you can store them all in one list. Lists can grow and change using built-in methods like .append() and .insert().

Learning Target

I can store and manipulate multiple values using lists in Python.

Your Turn: Thinking About Lists

In the code below, each value is stored in a separate variable. Why might someone do this instead of using a list?

city1 = "Dallas"
city2 = "Austin"
city3 = "Houston"
    

Task:

  • Open 126-list_operations.py use append() to add “sacramento” to the list and then use insert to add “Little rock” before “sacarmento”
  • What is the object and method in capitals.append("Sacramento")?
    • Object: Sacramento
    • Method: append
  • 🧠 Deeper Thinking

    1. Why does "Little Rock" appear twice when you run the program?
    2. What are two ways you could fix this?
      • a. Remove item one of the little rocks
      • b. check if the index is right

    Tasks:

    1. Open 126-analyze.py. What will the print() do?
    2. What kind of data structure is used on line 4?
    3. How would you change the coins list to use "bronze" instead of "platinum"?

    Notes

    • Append: capitals.append("Sacramento")
    • Insert before: capitals.insert(3, "Little Rock")
    • Reinforce that . accesses a method of the object before it.
    • Have You should verbalize how list operations affect code flow and output.

    Lesson 5: String + Number

    You can use str() to convert numbers into strings so they can be combined with text.

    Learning Target

    I can display numbers in sentences using str().

    age = 12
    print("I am " + str(age) + " years old.")
      

    Tasks:

    Create a variable for a number, convert it to a string, and print it in a sentence.

    Lesson: Assignment, Comparison & Logical Operators


    Assignment Operators

    Operators perform calculations and evaluate conditions. The six main types in Python are arithmetic, containment, comparison, identity, logical, and assignment. Assignment operators are used to set values to variables.

    Purpose

    Understand how assignment operators work and in what sequence they are executed.

    Steps for Completion

    1. Name the six types of operators in the order of execution--->assignment operators,logical operators, identity operators comparison operators,membership operators, and Arithmetic operators.
    2. Review the code and answer the following:
      • What will happen when this code is run--->#-----It will print that x is equal to 8
      • x = 5
        x += 3
        print("x is now:", x)
        

    Notes

    • Explain that variables take the most recent value assigned.
    • The variable on the left side of = is set to the value on the right side.

    Comparison Operators

    Comparison operators compare two values: equal to, not equal to, less than, greater than, less than or equal to, and greater than or equal to. They help determine whether a condition is met.

    Purpose

    Understand how Python uses comparison operators to evaluate expressions.

    Steps for Completion

    1. What type of value do comparisons return--->True and False
    2. In what sequence are comparisons evaluated--->left to right
    3. What happens if part of a comparison is false-->it returns false or is skipped in a conditional
    a = 10
    b = 20
    print(a == b)   # False
    print(a < b)    # True
    

    Logical Operators

    Logical operators in Python include not, and, and or. These operators follow a specific order of precedence and are essential for controlling flow based on multiple conditions.

    Purpose

    Learn how logical operators influence the flow of logic in code.

    Steps for Completion

    1. List the logical keywords in order of precedence:
      • a. not
      • b. and
      • c. or
    2. Review the code and answer the following:
      • What will happen when this code is run---> it will return true for line 2 and false for line 3

    Notes

    • If time permits, share additional examples of logical operators in Python code.
    x = 7
    print(x > 5 and x < 10)  # True
    print(not x == 7)        # False
    

    Lesson 6: Input from the User

    You can ask the user questions using the input() function. The user's response is stored as a string.

    Learning Target

    I can get and use input from a user in a program.

    name = input("What is your name? ")
    print("Hello, " + name + "!")

    Tasks:

    Ask the user their favorite color and print a message with their answer.

    Arithmetic

    Arithmetic has an order of operations when performing calculations. This order ensures that calculations are performed the same way every time to provide consistent results.


    Purpose

    Upon completing this project, you will better understand the order of operations.


    1. List the order of operations from first to last.
      • a. parentheses
      • b. exponenets
      • c. multiplication
      • d. divison
      • e. addition
      • f. subtraction

    Steps for Completion:

    Objectives covered:

    Identity Operator

    Two variables can appear equal, but one can use the identity operator to determine if they are truly the same. The identity operator determines if two variables share the same memory location.


    Purpose

    Upon completing this project, you will better understand the identity operator.


    Steps for Completion

    Containment Operator

    Containment is often used for lists, sets, tuples, and dictionaries. The containment operator checks whether a value is contained within a list of values.


    Purpose

    Upon completing this project, you will better understand the containment operator.


    Steps for Completion

    1. Containment operations happen after identity operations.
    2. Review the code, then answer the question about the containment operator.

    Objectives covered:


    Questions

    Review 1.3

    Purpose

    Upon completing this project, you will better understand the order of operations across categories of operators and within a category of operators.


    Steps for Completion

    1. What is the order for the six types of operators?
      • a. Arithmetic operators
      • b. Assignment operators
      • c. comparison operators
      • d. logical operators
      • e. Identity operators
      • f. Membership operators

    2. What supersedes all operators in the order of operations?
      • a. parentheses

    3. What is the order of preference for logical operators?
      • a. not
      • b. and
      • c. or

    4. What is the order of operations for arithmetic operators?
      • a. parentheses
      • b. exponents
      • c. multiplication
      • d. division
      • e. addition
      • f. subtraction

    Lesson 7: Integers from Input

    You can turn input into a number using int(). This allows you to do math with it.

    Learning Target

    I can collect numbers from a user and use them in calculations.

    age = int(input("How old are you? "))
    print("Next year you’ll be " + str(age + 1))

    Tasks:

    Ask the user how many siblings they have. Then print double that number in a sentence.

    Lesson 8: More Math

    You can perform different operations like subtraction, multiplication, division, and remainders using -, *, /, and %.

    Learning Target

    I can perform and understand different types of math operations in Python.

    apples = 9
    friends = 2
    print("Each friend gets", apples // friends, "apples")

    Tasks:

    Ask the user how many cookies they have and how many friends they’ll share with. Show how many each friend gets using division.

    Lesson 9: Using Comments

    Use # to add comments. These lines are ignored by Python but help humans understand the code.

    Learning Target

    I can use comments in my code to explain what it does.

    # This line prints a greeting
    print("Hello!")

    Tasks:

    Write a small program with at least two comments that explain what each part does.

    Lesson 10: Syntax and Errors

    Python will give an error if it doesn’t understand your code. These are called syntax errors.

    Learning Target

    I can recognize and fix syntax errors in Python code.

    # Incorrect: missing parenthesis
    print("Hello"
    # Fixed version
    print("Hello")

    Tasks:

    Fix this line of code with a syntax error:

    print("What's up"

    Lesson 11: Debugging

    Sometimes your code runs but doesn’t do what you expect. Use print() to see what’s happening and find bugs.

    Learning Target

    I can use print statements to debug and fix code.

    num = 10
    # We expect this to print 20, but it prints 30!
    print(num + 20)

    Tasks:

    Use print() to figure out what's wrong in a small buggy program. Then fix it.

    Lesson 12: Order of Operations

    Python follows PEMDAS rules for math: parentheses, exponents, multiplication/division, addition/subtraction.

    Learning Target

    I can use parentheses to control the order of operations in math expressions.

    print(3 + 2 * 4)      # 11
    print((3 + 2) * 4)    # 20

    Tasks:

    Write two print statements: one with parentheses and one without, using different math operations.

    Lesson 13: Mini-Project

    Let's combine everything we’ve learned into a short interactive project.

    Learning Target

    I can write a program that uses input, variables, math, and output.

    name = input("What's your name? ")
    birth_year = int(input("What year were you born? "))
    age = 2025 - birth_year
    print("Hi " + name + "! You are " + str(age) + " years old.")

    Tasks:

    Make your own short program! Use input, math, and strings to tell the user something fun or helpful.

    Lesson 14: More Data Types and String Slicing


    Learning Target

    I can use booleans, floats, the modulus operator, and slice strings in Python.

    Booleans

    Booleans represent truth values: True or False. They are often used in conditions.

    is_raining = True
    print("Bring an umbrella:", is_raining)

    Floats

    Floats are numbers with decimal points.

    price = 4.99
    tax = 0.40
    total = price + tax
    print("Total:", total)

    Modulus Operator

    The modulus operator % returns the remainder of a division.

    print(10 % 3)  # Output: 1
    print(15 % 4)  # Output: 3

    String Slicing

    You can extract parts of a string using slicing.

    word = "Python"
    print(word[0:3])  # Output: Pyt
    print(word[2:])   # Output: thon
    print(word[-1])   # Output: n

    Tasks:

    Try writing a program that:

    • Defines a float variable for a meal price
    • Calculates tax using a float
    • Prints whether the total is over \$10 using a boolean
    • Prints the first 3 letters of a string using slicing

    Try it here: