Please enable JavaScript to use CodeHS

Introduction to Python Programming

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 Karel the Dog and how Karel can be given a set of instructions to perform a simple task.

Objective

Students will be able to:

  • Recognize, explain, and use the commands that Karel can be given. These commands are: move(), put_ball(), take_ball() and turn_left().
Description

In this lesson, students build on their understanding of how Karel the Dog can be given a set of instructions to perform a simple task.

Objective

Students will be able to:

  • Recognize, explain, and use the commands that Karel can be given
  • Debug and rework their code as well as someone else’s code
Description

In this lesson, students will learn how to define and call a function using proper syntax.

Objective

Students will be able to:

  • Define and call functions
Description

In this lesson, functions will be used to teach Karel a new word or command. Using functions allows programs to be broken down into smaller pieces and makes it easier to understand.

Objective

Students will be able to:

  • Understand what functions are, how they are used and how using them improves programs
  • Design and implement their own functions to solve problems
Description

In this lesson, students learn top down design and decomposition as the processes of breaking big problems into smaller, manageable pieces. The functions improve the readability of the code and avoid repeated code.

Objective

Students will be able to:

  • Break a large problem down into smaller, simpler problems
  • Write functions that solve the simpler problems, and use them as building blocks to solve the larger problem
  • Compare programs and identify good vs. poor decomposition
Description

In this lesson, students will learn how to utilize comments in their code to explain what their code is doing. Comments should include preconditions and postconditions. Preconditions are assumptions we make about what is true before a function is called in our program. Postconditions are what should be true after a function is called in our program.

Objective

Students will be able to:

  • Explain the preconditions and postconditions of a function
  • Create clear and readable comments in their code that help the reader understand the code
  • Explain the purpose of comments
Description

In this lesson, students will learn about abstraction. Abstraction is the act of managing complexity by dissociating information and details in order to focus on relevant concepts.

Objective

Students will be able to:

  • Understand abstraction as the different levels of detail and complexity
  • Understand the importance of abstracting away complexity to solve problems more efficiently
Description

In this lesson, students will be introduced to SuperKarel and APIs. SuperKarel includes commands like turn_right() and turn_around() since they are so commonly used. These commands come prepackaged with the SuperKarel library (API).

Objective

Students will be able to:

  • Write programs that use SuperKarel instead of Karel
  • Utilize the new toolbox of commands that SuperKarel provides over Karel
  • Read the documentation to understand how to use an API (SuperKarel is an example of this)
Description

In this lesson, students learn how to use for loops in their programs. The for loop allows you to repeat a specific part of code a fixed number of times.

A for loops is written as follows:

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 will learn about conditions and if statements. A condition is a function that returns a true/false answer. Python uses if statements as a way to make decisions and execute specific code. If statements are helpful in writing code that can be used in different situations.

Objective

Students will be able to:

  • Use conditions to gather information about Karel’s world (is the front clear, is Karel facing north, etc)
  • Create if statements to only execute code if a certain condition is true
Description

In this lesson, students will take a deeper look into conditional statements, more specifically if/else statements. If/else statements allow for one thing to be done if a condition is true, and something else otherwise.

We write if/else statements like this:

if front_is_clear():
    # code to execute if front is clear
elif balls_present():
    # code to execute otherwise
Objective

Students will be able to:

  • Explain the purpose of an If/Else statement
  • Create If/Else statements to solve new types of problems
  • Identify when an If/Else statement is appropriate to be used
Description

In this lesson, students are introduced to a new type of loop: while loops. While loops allow Karel to repeat code while a certain condition is true. While loops allow for the creation of general solutions to problems that will work on multiple Karel worlds, rather than just one.

Objective

Students will be able to:

  • Explain the purpose of a while loop
  • Create while loops to repeat code while a condition is true
  • Utilize while loops to solve new types of problems
  • Test their solutions on different Karel worlds
Description

In this lesson, students take a look at all of the control structures. Control structures can be selective, like if and if / else statements and are based on a condition. Other control structures are iterative and allow for repeated code like for loops and while loops. Basically, control structures control the way the commands execute.

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

Debugging is a very important part of programming. In this lesson, students learn how to effectively debug their programs.

Objective

Students will be able to use debugging strategies to find and fix errors in their code.

Description

In this lesson, students are introduced to algorithms which are step by step instructions that solve a problem. Programs implement algorithms. All algorithms are built using sequencing, selection, and iteration. Karel has control structures for each of these. This lesson is designed to test students’ knowledge of control structures and algorithm design in preparation for upcoming Karel challenges.

Objective

Students will be able to:

  • Analyze an algorithm and explain why it works
  • Use control structures to create general algorithms that work on all Karel worlds
Description

In this lesson, students are introduced to Ultra Karel! Ultra Karel has all the abilities of Super Karel, plus two new functions (paint and color_is) added to the API.

Students will explore the Ultra Karel API and use Ultra Karel’s ability to paint the grid world to create digital images. Students will create generalized algorithms that solve Ultra Karel problems for multiple worlds.

This lesson is the first time students will use functions that accept parameters as inputs.

Objective

Students will be able to:

  • Use Ultra Karel commands to paint Karel’s world
  • Call functions that accept parameters as inputs
  • Explain the relationship between a function and a parameter
  • Create generalized Ultra Karel algorithms that correctly solve multiple Karel worlds
  • Identify differences between the Super Karel API and the Ultra Karel API
Description

In this lesson, students will synthesize all of the skills and concepts learned in the Karel unit to solve increasingly challenging Karel puzzles.

Objective

Students will be able to:

  • Define a problem in their own words and plan out a solution to the problem
  • Break a large problem down into smaller pieces and solve each of the pieces, then use these solutions as building blocks to solve the larger problem
  • Utilize the proper control structures to create general solutions that solve multiple Karel worlds
  • Write clear and readable code using control structures, functions, decomposition, and comments
Description

In this lesson, students complete a summative assessment of the unit’s learning objectives.

Objective

Students will be able to:

  • Prove their knowledge of control structures, functions, decomposition, and comments 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

Students will have an opportunity to be creative and apply all they’ve learned about basic python and variables to create a Mad Libs game a user can interact with.

Objective

Students will be able to:

  • Come up with a silly Mad Libs template
  • Use Basic Python concepts (Printing, User Input, Variables) to create an interactive program
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

Students will have an opportunity to be creative and apply all they’ve learned about conditionals to create a Quiz game a user can interact with.

Objective

Students will be able to:

  • Create a multi-question quiz on a topic of their choice
  • Use conditionals to check a user’s answers and keep track of their score
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

Students will have an opportunity to apply all they’ve learned about looping to create a password authentication program a user can interact with.

Objective

Students will be able to:

  • Use looping to continually check if the information a user has entered is correct
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

Students will have an opportunity to apply many of the concepts they’ve learned so far to create a game where the user can compete against the computer to earn the high score.

Objective

Students will be able to:

  • Combine their knowledge of loops, functions, and conditionals to create an interactive game
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 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

Students will have an opportunity to apply many of the concepts they’ve learned so far to create a word-guessing game.

Objective

Students will be able to:

  • Combine their knowledge of loops, functions, conditionals, strings, and data structures to create an interactive word-guessing game
Description

This lesson outline focuses on explaining the concepts and importance of file I/O without delving into coding syntax. It provides a foundation for students to understand the fundamentals before diving into the actual coding aspects in subsequent lessons.

Objective

Students will be able to:

  • Define and explain file I/O.
  • Differentiate file types (e.g., text, binary).
  • Identify input sources and output destinations in computing.
  • Understand the purpose and significance of file input.
  • Understand the purpose and significance of file output.
  • Discuss real-world applications of file I/O.
Description

In this lesson, students learn how to read all or a given number of characters from a file using Python.

Objective

Students will be able to

  • Understand the importance of reading files and the role it plays in file handling tasks.
  • Use the open() function to open a file in read mode and the close() method to close the file properly.
  • Read the entire contents of a file using the read() method and store them in a variable
  • Handle common file exceptions, such as FileNotFoundError, when attempting to read a file.
Description

In this lesson, students learn how to use the readline() method to read lines from a file.

Objective

Students will be able to:

  • Understand the purpose and usage of the readline() method in Python for reading lines from a file.
  • Demonstrate how to open a file and use readline() to read a single line at a time.
  • Implement a loop to read and process multiple lines from a file using readline().
  • Handle end-of-file (EOF) situations by checking for an empty string returned by readline().
  • Adapt the readline() method to solve practical problems and perform operations on each line read from a file.
Description

In this lesson, students learn how to use the readlines() method in Python to read multiple lines from a file, and practice performing various operations and manipulations on the line

Objective

Students will be able to:

  • Understand the purpose and usage of the readlines() method in Python.
  • Read and retrieve multiple lines from a file using readlines().
  • Iterate through the lines obtained from readlines() and perform operations on each line.
  • Apply different manipulations and processing techniques to the lines read from a file.
  • Recognize the advantages and use cases of using readlines() in file handling scenarios.
Description

In this lesson, students learn how to write to existing files. They will explore two modes: “w” for overwriting a file and “a” for appending to a file.

Objective

Students will be able to:

  • Understand the purpose and importance of writing to files in programming.
  • Use the “w” mode to overwrite the contents of a file.
  • Use the “a” mode to append new data to the end of a file.
  • Demonstrate the ability to write text and data to a file using appropriate file handling techniques.
Description

In this lesson, students learn how to manipulate the file pointer position using the seek() method in Python. They will explore how seek() can be used to move the pointer to a specific location within a file, enabling reading and writing operations at desired positions.

Objective

Students will be able to:

  • Understand the concept of a file pointer and its role in reading and writing data.
  • Use the seek() method to move the file pointer to a specific position within a file.
  • Perform reading operations at a desired file pointer position.
  • Perform writing operations at a specific location within a file.
  • Identify and handle potential errors or exceptions related to seek() operations.
Description

In this lesson, students will explore the vital role of software engineers within a software engineering team. They will learn how software engineers collaborate, communicate, and contribute their specialized skills to develop and maintain high-quality software applications that meet the needs of users.

Objective

Students will be able to:

  • Understand the responsibilities and functions of software engineers within a software engineering team.
  • Identify the skills and knowledge required to be a successful software engineer on a team.
  • Gain insights into real-world examples of software engineering projects and the impact of software engineers on the final product.
Description

In this lesson, students will explore the important role of Quality Assurance (QA) engineers on a software engineering team. They will learn about the responsibilities of QA engineers, their impact on software quality, and how their expertise ensures a smooth user experience.

Objective

Students will be able to:
* Understand the role and responsibilities of QA engineers in a software engineering team.
* Recognize the importance of quality assurance in ensuring software reliability and user satisfaction.
* Explore the techniques and methods used by QA engineers to identify and report software defects.

Description

In this lesson, students will explore the vital role of designers on software development teams and learn how they collaborate with developers to create intuitive and visually appealing user interfaces.

Objective

Students will be able to…

  • Understand the specific tasks and responsibilities of designers within a software development team
  • Examine fundamental design principles such as color theory, typography, and accessibility
  • Assess the impact of well-designed user interfaces on user experience
Description

In this lesson, students will explore the crucial role of a project manager within a software engineering team, understanding their responsibilities in planning, coordinating, and executing projects.

Objective

Students will be able to:

  • Understand the role and responsibilities of a project manager within a software engineering team.
  • Identify the key skills and qualities required to be an effective project manager in the software engineering field.
  • Explore the importance of effective communication and collaboration in project management and its impact on project success.