Please enable JavaScript to use CodeHS

Teaching Intro to Computer Science in Python 3

Description

In this lesson, you’ll learn how to make the most basic python program, one that displays texts on the screen. When you run these programs, you’ll see text appear on the console screen. You will learn how to print in python using the print statement. You will also learn how to use quotations, apostrophes, and strings.

Objective

Students learn how to print text in Python.

Description

In this video, students will learn about a fundamental aspect of every programming language: Variables. A variable is something that stores information in a program that you can use later. More specifically, a variable has 3 things: a name, type, and value. One of the variables students will be presented is Greeting.

Objective

SWBAT define Python variables and types.

Description

In this lesson, we cover user input. We learn how to request user input as both strings and integers, we learn where the input is stored, and we learn how to convert strings and integers. By converting strings to integers, students can incorporate their knowledge from the previous lesson (Mathematical Operators) with this lesson on user input.

Objective

SWBAT incorporate user input into their programs.

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 we will discuss what is a Boolean and go over examples.

Objective

Students learn about booleans and how they might be useful in their programs.

Description

In this lesson we will learn how to use If and If-Else Statements; these statements allow you to use conditions to determine how your code should run.

Objective

Students learn how 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
  • While loops allow code to be executed repeatedly based on a condition.
  • It might be helpful to think of while loops as a repeating if statement.
  • 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.
Objective

Students learn how to effectively use while loops in their programs and to watch out for 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
  • When we use control structures within control structures, we refer to them as nested control structures.
  • When using a for loop within a for loop, we need to be careful to create a second variable to index on.
  • The inner loop will run to completion every time the outer loop runs.
Objective

Students build upon their control structures knowledge to start using nested control structures in their programs.

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