Skip to main content
Contents
Dark Mode Prev Up Next Scratch ActiveCode Profile
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 3 (3/5) Introduction to Parsons Puzzles
Welcome to the Parsons Puzzles practice session! In this section, you will get familiar with how Parsons Puzzles work before attempting the actual test puzzles.
A Parsons Puzzle presents you with all the lines of code needed to solve a programming task, but they are mixed up. Your job is to:
Drag the code blocks from the left side to the right side
Arrange them in the correct order
Set the proper indentation for each line
Letβs start with a simple practice puzzle to get you comfortable with the interface.
Subsection 3.1 Practice Puzzle 1: Simple Function
This is a simple warm-up problem. Try to arrange the code blocks in the correct order to create a function that prints a greeting message.
Question 3.1.1 .
Arrange the following code blocks to create a function called
greet that takes a name as a parameter and prints "Hello, [name]!"
def greet(name):
---
message = "Hello, " + name + "!"
---
print(message)
Tips for solving Parsons Puzzles:
Read the problem description carefully
Think about the logical flow of the program
Pay attention to indentation - it matters in Python!
Use the Check button to test your solution
Donβt worry if you make mistakes - you can try again
Subsection 3.2 Practice Puzzle 2: Conditional Statement
Now letβs try a slightly more complex problem that involves a conditional statement.
Question 3.2.1 .
Arrange the code blocks to create a function called
check_positive that takes a number as a parameter and returns
True if the number is positive, and
False otherwise.
def check_positive(num):
---
if num > 0:
---
return True
---
else:
---
return False
Subsection 3.3 Practice Puzzle 3: With Paired Distractors
This puzzle includes
paired distractors . For some steps, you will be presented with a choice between a correct code block and an incorrect one. Your job is to identify and use only the correct block from each pair. This is what youβll see in the test problems.
Question 3.3.1 .
Arrange the code blocks to create a function called
is_even that takes a number and returns True if itβs even, False if itβs odd.
def is_even(num):
---
if num % 2 == 0:
---
if num % 2 = 0: #paired
---
return True
---
else:
---
return False
---
return true #paired
Notice: You had to choose the correct line from pairs of correct and incorrect code. In the test, youβll also need to identify which lines are correct and which are distractors.
Subsection 3.4 Are You Ready?
Great work on the practice problems! You should now be familiar with:
How to drag and drop code blocks
How to arrange blocks in the correct order
How to set proper indentation
How to check your solution and interpret feedback
Question 3.4.1 .
Do you feel ready to proceed to the actual Parsons Puzzles test?
When youβre ready, click the Next button to begin the test section.
Remember: In the test section, you will have four puzzles to solve. Take your time, read each problem carefully, and do your best!