AdaptEd
Pod · look-only preview

Python Variables and Comments for Beginners

Grade 5 Computer Science TEKS PY.2A, PY.1B 5 slides · 11 questions
Shared by Ochoa
Sign in to make a copy
Teachers: your copy includes the answer key.
Use with my class
No account needed. You get a link for students and a private page with their scores.
The answer key isn't shown here. Nothing you do on this page is saved or graded.
Opening

🤔 What Do You Think?

A computer screen filled with colorful lines of Python code, including words starting with # and words next to equals signs.
Slide 1

What Are Comments in Python?

Comments
— Notes in code starting with # that explain what the code means.
Check for understanding

Check Your Understanding

Categorize

Sort each item as either a comment or code.

Drag each item into the bucket it belongs in, or click an item and then a bucket. Click an item in a bucket to send it back.

Comment
Code
0 / 4 placed
Slide 2

Creating and Using Variables in Python

Variables
— Names that store information like numbers or text in code.
Assignment
— Giving a value to a variable using the = sign.
Check for understanding

Check Your Understanding

Code PYTHON

Write Python code to create a variable called city with the value "Austin" and print it.

Create a variable named city and assign it the word "Austin" as its value. Then, print the value of city.
0/100 characters Waiting for input
Slide 3

Variable Naming Rules and Unpacking

Unpacking
— Taking multiple values from a list and saving them into variables at once.
Check for understanding

Check Your Understanding

Select 2 Correct Answers

Which of these are valid Python variable names?

Click all the correct answers — there are 2 right options.

0 selected
Slide 4

Using Comments and Variables Together

Debug
— Finding and fixing mistakes in your code.
Check for understanding

Check Your Understanding

Code PYTHON

Write Python code to assign 3 values 1, 2, 3 to variables a, b, c in one line, then print a.

Assign the values 1, 2, and 3 to variables a, b, and c all in one line using unpacking. Then print the value of a.
0/100 characters Waiting for input
Check for understanding

Solo Run: Variables and Comments

Code PYTHON

Create two variables named fruit and color. Assign "apple" to fruit and "red" to color. Then print both variables on separate lines.

Create variables fruit and color, assign "apple" and "red" to them, then print each variable on its own line.
0/200 characters Waiting for input
Categorize

Sort these as either valid or invalid Python variable names.

Drag each item into the bucket it belongs in, or click an item and then a bucket. Click an item in a bucket to send it back.

Valid
Invalid
0 / 4 placed
Pick 1 Correct Answer

Which of the following code lines correctly unpack the values 10 and 20 into variables x and y?

Choose the one correct answer.

Code PYTHON

Write Python code to add a comment saying "This is the player's age" above a variable age assigned the number 12, then print age.

Write a comment '# This is the player's age' above the variable assignment age = 12. Then print age.
0/200 characters Waiting for input
Exit check

Show What You Know: Python Variables and Comments for Beginners

Select 2 Correct Answers

Which of these are correct ways to assign values to variables in Python?

Click all the correct answers — there are 2 right options.

0 selected
Matching

Match each term to its correct explanation.

Drag a term onto its definition, or click one item from each column to match them.

Terms
Variable
Unpacking
Comment
Assignment
Definitions
Using = to give a value to a variable
A note in code starting with # that explains what the code does
Assigning multiple variables their values in one line
A named box storing a value like a number or word
0 of 4 matched
Sorting

Put these steps in the correct order for creating variables and printing a value in Python.

Drag and drop the items to put them in the correct order.

First / Top Last / Bottom
  • Assign values to variables using 'a, b = 5, 10'
  • Write comments to explain what the code does
  • Use print() to show the value of a variable
  • Run the Python program to see the output