Please enable JavaScript to use CodeHS

Intro to Computer Science in Python

Description

This lesson introduces students to an overview of the Intro to Python course while probing their thinking on what it means to be successful in an online (or blended learning) course.

Objective

Students will be able to:

  • describe the audience, relevance, and outcomes of the Intro to Python course
  • reflect on the practices and strategies that will help them be successful in an online (or blended) learning class
Description

In this lesson, students are introduced to coding with turtle graphics. Students will begin to recognize programs as sequences and groups of commands. Students will learn a few basic commands and then apply them right away by writing their first program.

Objective

Students will be able to:

  • Define programming/coding
  • Use basic Tracy commands
  • Write their first program
Description

In this lesson, students will be introduced to the layout of Tracy’s grid world and will learn how to use coordinate pairs to locate Tracy on the coordinate plane. They will add to the list of commands they know and can use to create Tracy graphics.

Objective

Students will be able to:

  • Locate Tracy on the coordinate plane
  • Use the penup(), pendown(), and backward() commands in their programs
Description

In this lesson, students will learn how to use the left and right commands in order to move Tracy to more locations on the canvas. They will now have many commands that can be used to have Tracy create more complex graphics.

Objective

Students will be able to:

  • Use the left and right commands in order to move Tracy around her grid world
Description

In this lesson, students are introduced to for loops. They learn how for loops simplify the process of making small changes to a program and help avoid repeating code. For loops are written like this:

for i in range (4):
    // Code to be repeated 4 times
Objective

Students will be able to:

  • Create for loops to repeat code a fixed number of times
  • Explain when a for loop would be a useful tool
  • Utilize for loops to write programs that would be difficult / impossible without loops
Description

In this lesson, students are introduced to the ability to turn Tracy at any angle. With this feature, Tracy can now draw diagonal lines which opens up the possibility to draw multiple shapes that weren?t previously available.

Objective

Students will be able to:

  • Use angles inside turning commands
  • Turn Tracy at angles in conjunction with for loops
Description

In this lesson, students learn how to use comments to describe their programs. Comments are helpful because they allow programmers to leave notes about the programs they are writing. Students will also learn about the different types of comments that can be used and the benefits of using them.

Objective

Students will be able to:

  • Use comments throughout their program
  • Describe why comments are helpful for both themselves and anyone else looking at their code
Description

In this short lesson, students will be introduced to the rules for naming elements in their code. Variables and functions that are used inside their programs will be named by students, so the following guidelines should be obeyed to be sure that the programs written are readable and successful.

Objective

Students will be able to:

  • Name elements of their code by following specific guidelines and rules in order to create readable and working programs
Description

In this lesson, students are introduced to functions. They start with the basics of defining a function and why we need them and will revisit a program they coded earlier in the unit to rewrite it using functions.

Objective

Students will be able to:

  • Define a function
  • Call a function
  • Explain why functions are used
Description

In this lesson, students are able to add some flair to their turtle graphics programs by controlling color, pensize, and fill. These new commands are added to the list of commands that have been already practiced in order to allow for more creativity in student programs.

Objective

Students will be able to:

  • Use the extended circle() command to draw different shapes
  • Use the color(), pensize(), begin_fill(), and end_fill() commands to add more creativity to their programs
Description

In this lesson, students are introduced to the concept of Top Down Design. Top Down Design is the process of breaking down a program into functions or smaller parts to avoid repeated code and to make our programs more readable.

Objective

Students will be able to:

  • Break a large problem down into smaller pieces
  • Write functions to solve each smaller problem
  • Solve a complicated problem using Top Down Design
Description

In this lesson, students will learn about a fundamental aspect of every programming language: Variables. A variable is something that stores information in a program that can be used later.

Objective

Students will be able to:

  • Describe what variables are
  • Discuss why variables are used in our programs
Description

In this lesson, students will learn how to incorporate user input into their programs. Students will learn how to request user input as both strings and integers, where the input is stored, and how to convert strings and integers.

Objective

Students will be able to:

  • Incorporate user input into their code in order to customize their programs
Description

In this lesson, students will dive deeper into the concept of functions by exploring how to use parameters to customize their code.

Objective

Students will be able to:

  • Incorporate parameters into their functions in order to adapt their functions to multiple situations
Description

In this lesson, students will expand their knowledge of for loops. They are aware that for loops execute the same lines of code a given number of times but will learn that i is actually a variable that can be used to control commands inside the loop as it is running.

Objective

Students will be able to:

  • Use i as a variable inside their for loop to control different commands
Description

In this lesson, students will learn the extended parameters that can be used to control the value of i in for loops. They will then be able to use the variable i to control much more of their code by setting specific values.

Objective

Students will be able to:

  • Control the value of i using extended parameters
Description

In this lesson, students will learn how to use If Statements which will allow them to use conditions to determine how their code should run.

Objective

Students will be able to:

  • Use if statements in order to tell Tracy how to make decisions
Description

In this lesson, students will learn how to expand on If Statements by including a way to have Tracy make decisions between multiple scenarios.

Objective

Students will be able to:

  • Use if/else statements in order to have Tracy make decisions between multiple scenarios
Description

In this lesson, students will learn that while loops allow code to be executed repeatedly based on a condition. They will also be warned that infinite loops are created if the exit condition of the while loop is never met, causing the code inside the while loop to repeat continuously which causes the program to crash.

Objective

Students will be able to:

  • Effectively use while loops in their programs
  • Identify infinite loops
Description

In this lesson, students will put together all the concepts they?ve learned thus far. They will be able to use top down design and to write programs that will solve complex problems.

Objective

Students will be able to:

  • Identify the different control structures we can use to modify the flow of control through a program
  • Combine control structures to solve complicated problems
  • Choose the proper control structure for a given problem
Description

In this lesson, students review content with a 25 question End-of-Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of control structures and coding concepts through a multiple choice quiz
Description

In this lesson, students will learn how to make the most basic python program- one that displays text on the screen. Students will learn how to print in python using the print statement. They will also learn how to use quotations, apostrophes, and strings.

Objective

Students will be able to:

  • Print text in Python
Description

In this lesson, students will be reintroduced to the concept of variables, which store information in a program to be used later. Students will also learn about three different variable types- strings, integers, and floating point numbers.

Objective

Students will be able to:

  • Define Python variables and types
Description

In this lesson, students revisit user input. They learn how to request user input as both strings and integers, learn where the input is stored, and learn how to convert strings and integers.

Objective

Students will be able to:

  • Incorporate user input into their programs
  • Convert between variable types
Description

In this lesson, students will learn about using mathematical operators in their Python programs. They will work through multiple examples to get comfortable with operator precedence and using different types of operators.

Objective

Students will be able to:

  • Describe the different mathematical operators that can be used in their programs
  • Create programs that use basic math to compute useful things
  • Create programs that take in user input, do simple computations with the input, and produce useful output
Description

In this lesson, students will be able to perform string operations in order to concatenate values together.

Objective

Students will be able to:

  • Use mathematical operators with strings
Description

In this lesson, students revisit the concept of comments. Comments are helpful because they allow programmers to leave notes about the program they are writing.

Objective

Students will be able to:

  • Incorporate comments into their programs in order to make them more readable
Description

In this lesson, students review content with a 20 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of basic coding concepts through a multiple choice quiz
Description

In this lesson, students will revisit the concept of boolean values. Booleans refer to a value that is either true or false. Named after English-born mathematician, philosopher and logician, George Boole, Booleans are used to test whether a condition is true or false.

Objective

Students will be able to:

  • Create boolean variables to represent meaningful yes/no values
  • Print out the value of a boolean variable
Description

In this lesson, students will review how to use If and if/else statements. These statements allow programmers to use conditions to determine how their code should run.

Objective

Students will be able to:

  • Use if statements for control flow in their programs
Description

In this lesson, students will dive into comparison operators. Comparison operators give the ability to compare two values. Using comparison operators in programming is similar to math in that less than <, greater than >, less than or equal to <=, and greater than or equal to >= are the same. The differences are that operators for equal to are == and not equal are !=. Using comparison operators allow programs to make decisions.

Objective

Students will be able to:

  • Explain the meaning of each of the comparison operators (<, <=, >, >=, ==, !=)
  • Create programs using the comparison operators to compare values
  • Predict the boolean result of comparing two values
  • Print out the boolean result of comparing values
Description

In this lesson, students will look at logical operators. Logical operators give the ability to connect or modify Boolean expressions. Three logical operators are NOT (!), or and and. These logical operators can be used in combination. With these logical operators, logical statements can be constructed, such as ?I go to sleep when I am tired OR it?s after 9pm?, ?I wear flip flops when I am outside AND it is NOT raining?.

Objective

Students will be able to:

  • Describe the meaning and usage of each logical operator: or, and, and NOT (!)
  • Construct logical statements using boolean variables and logical operators
Description

In this lesson, students learn about the intricacies of floating point numbers. When using comparison operators with floating point numbers in Python, we will sometimes see strange behavior because of bizarre rounding methods. When using a comparison operator with floating point numbers, you should use round(x) to avoid strange rounding behavior. round(x, n) will round the float x to n decimal places. round(x) will round the float x to 0 decimal places.

Objective

Students will be able to:

  • Use floating point numbers
  • Round values in their programs
Description

In this lesson, students review content with a 15 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of conditionals through a multiple choice quiz
Description

In this lesson, students learn to use while loops in their Python programs. While loops allow code to be executed repeatedly based on a condition. They are also reminded of the possibility of creating an infinite loop, which occurs if the exit condition of the while loop is never met, causing the code inside the while loop to repeat continuously.

Objective

Students will be able to:

  • Effectively use while loops in their programs
  • Detect and resolve infinite loops
Description

In this lesson, students will explore how to use for loops in their Python programs. They will be reminded how to use i as a variable in their programs as well as how to control the values of i by altering the starting, ending, and interval values.

Objective

Students will be able to:

  • Implement for loops
  • Use the variable i as a counter
  • Control the values of i in a for loop
Description

In this lesson, students learn about break and continue statements. A break statement is used to immediately terminates a loop. A continue statement is used to skip out of future commands inside a loop and return back to the top of the loop. These statements can be used with for or while loops.

Objective

Students will be able to:

  • Explain the critical difference between break and continue
  • Describe why a break or continue statement would be needed in a coding scenario
Description

In this lesson, students will use control structures within control structures, which are referred to as nested control structures.

Objective

Students will be able to:

  • Identify the different control structures that can be used to modify the flow of control through a program
  • Combine control structures to solve complicated problems
  • Choose the proper control structure for a given problem
Description

In this lesson, students review content with a 15 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of loops through a multiple choice quiz
Description

In this lesson, we learn about Functions. Functions let us break our program into different parts that we can organize and reuse however we like. Functions are the main building block of complex Python programs.

Objective

Students will be able to:

  • modularize their programs with functions
Description

In this lesson, we dive deeper into the concept of functions by exploring how to use parameters.

Objective

Students will be able to:

  • Effectively use parameters to customize functions in their programs
Description

In this lesson, we explore where variables exist and what the difference is between a local and global variable.

Objective

Students will be able to:

  • describe the different namespaces with regards to variables and functions
Description

In this lesson, students explore functions with return values and deepen their understanding of and ability to use functions.

Objective

Students will be able to:

  • remove complexity from their programs by abstracting with functions
  • generalize their functions with parameters
  • chain functions together using return values
Description

In this lesson, students explore Python’s way of handling errors with exceptions.

Objective

Students will be able to:

  • create programs that can gracefully handle exceptions
  • continue to function when an error is raised
Description

In this lesson, students review content with a 15 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of functions and exceptions through a multiple choice quiz
Description

Students will learn how indexing can be used to specify a specific character in a string based on location.

Objective

Students will be able to:

  • use indexing in order to find a specific character in a string
Description

Students will learn how slicing allows them to select multiple string values at once from a given string.

Objective

Students will be able to:

  • use slicing to select a set of values from a string
Description

In Python, strings have the property of “immutability” which means they cannot be mutated or changed. You can assign strings to variables, and reassign new strings to the same variable, but individual characters within a string cannot be reassigned.

Objective

Students will be able to:

  • explain what immutability is and how this applies to strings in Python
Description

In this lesson, students will look at the use of for loops with strings. Since both string indices and for loops index at zero, the len value can be used to go through strings in a for loop. Indicies don’t need to be explicitly used. The syntax for character in my_string can be used to go through a for loop one character at a time.

Objective

Students will be able to:

  • iterate over characters in a string using for loops
Description

In this lesson, students will see how the in keyword can be used in an if statement to see if a particular letter or substring is in a string.

Objective

Students will be able to:

  • use the in keyword to check if a character is in a string
Description

In this lesson, students will learn about string methods. Methods are basically functions that you call on objects and can be used to alter our strings in different ways.

Objective

Students will be able to:

  • use various string methods to alter string values
Description

In this lesson, students review content with a 20 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of strings through a multiple choice quiz
Description

In this lesson, students will learn about and practice using tuples. A tuple is a heterogenous, immutable data type that stores an ordered sequence of things that can be accessed using indices.

Objective

Students will be able to:

  • create and store information in tuples
  • explain the characteristics of a tuple
Description

In this lesson, students will learn about their second data structure, lists. A list is a mutable, heterogeneous data type that stores an ordered sequence of things.

Objective

Students will be able to:

  • understand and explain the characteristics of a list
  • use lists to store and recall information
Description

In this lesson, students will learn how lists can be iterated over in a similar way to strings.

Objective

Students will be able to:

  • understand and explain the characteristics of a list
  • use for loops to go through items in a list
Description

Methods, in general, are like functions that can be called on objects. Students have seen previously how string methods are called on strings. In this lesson, students will learn about the various list methods that can be called on lists!

Objective

Students will be able to:

  • apply useful list methods to alter and access information about a list
Description

In this lesson, students review content with a 15 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of basic data structures through a multiple choice quiz
Description

In this lesson, students will learn how 2d lists are stored and how to use indexing and slicing to extract specific items from a list of lists.

Objective

Students will be able to:

  • Use 2d lists to store information in rows and columns
Description

In this lesson, students will learn how to use list comprehensions to alter the items in a list with one line of code.

Objective

Students will be able to:

  • Perform list comprehensions in order to alter all items in a list at once
Description

In this lesson, students will learn how packing and unpacking makes assigning variables to list items very easy and quick.

Objective

Students will be able to:

  • Pack and unpack lists in order to quickly and efficiently assign variables to list items
Description

In this lesson, students will see how dictionaries differ from other data structures and why they are useful.

Objective

Students will be able to:

  • Use dictionaries to structure data
Description

In this lesson, students will learn the difference between equivalence and identity of values.

Objective

Students will be able to:

  • Predict if two values are identical and/or equivalent
Description

In this lesson, students review content with a 15 question Unit Quiz.

Objective

Students will be able to:

  • Prove their knowledge of data structures through a multiple choice quiz
Description

This project is broken up into several pieces to guide students through the game development.

Objective

Students will be able to:

  • use all concepts learned in this course to create a word guessing game in Python.
Description

Student has completed the entirety of the Intro to Computer Science in Python course!
Encourage to continue learning about Python with the supplemental lessons and projects.

Objective

N/A

Description

In this lesson, students review content with a final exam.

Objective

Students will be able to:

  • Prove their knowledge of coding in Python through a final exam