Python Programming Concepts Quiz

Python Programming Concepts Quiz

9th Grade

45 Qs

quiz-placeholder

Similar activities

Python L1 Concepts

Python L1 Concepts

1st - 12th Grade

40 Qs

Python Final exam 2025

Python Final exam 2025

6th - 9th Grade

48 Qs

EV3Robots

EV3Robots

9th - 12th Grade

45 Qs

Programming with Sphero (End-of-Year Review)

Programming with Sphero (End-of-Year Review)

KG - 12th Grade

40 Qs

AP CSP Unit 1

AP CSP Unit 1

9th - 12th Grade

40 Qs

Unit 1 Code.org AP CSP

Unit 1 Code.org AP CSP

9th - 12th Grade

40 Qs

CodeHS Unit 2

CodeHS Unit 2

6th - 10th Grade

50 Qs

Tynker Python 101 Unit Test

Tynker Python 101 Unit Test

8th - 12th Grade

50 Qs

Python Programming Concepts Quiz

Python Programming Concepts Quiz

Assessment

Quiz

Computers

9th Grade

Medium

Created by

Kirk Ellern

Used 3+ times

FREE Resource

45 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Suppose you write a function. How many times can you call the function in your code?

Once

Not more than the number of commands the function holds

It depends on the function

As many times as you want

Answer explanation

You can call a function as many times as you want, regardless of its internal commands. This flexibility allows for repeated execution, making the correct answer 'As many times as you want'.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In which of the following situations would it be best to make a function?

A. You want Tracy to draw a blue line, and your program requires lots of blue lines.

B. You need Tracy to move forward by 100.

C. You need Tracy to turn right and then turn left.

D. You need to change Tracy's color.

Answer explanation

Creating a function for drawing blue lines (Choice A) is efficient since it allows you to reuse the same code multiple times, reducing redundancy. The other options involve single actions that don't benefit from a function.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Fill in the blank: A function in programming is a reusable block of code that performs a specific task. You can call a function ______ times in your code.

once

twice

multiple

zero

Answer explanation

A function can be called multiple times in your code, allowing for code reuse and modularity. This flexibility is essential for efficient programming, making 'multiple' the correct choice.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following pieces of code will make Tracy do the following actions three times: go forward, change colors, and then turn around?

for i in range(4): forward(30) color("blue") left(180)

for i in range(3): forward(30) color("blue") left(180) color("red")

for i in range(3): backward(30) color("blue") left(180)

forward(30) color("blue") left(180) forward(30) color("green") left(180) forward(30) color("orange") left(180)

Answer explanation

The correct choice is the second option. It correctly repeats the actions of going forward, changing colors, and turning around three times, with an additional color change to red after each turn.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following functions would be the most useful function to write in order to solve this problem?

# Has Tracy draw a single triangle def make_triangle():

# Change's Tracy's color to red def change_to_red():

# Moves Tracy forward by 100 def move_100():

# Draws a square def my_function():

Answer explanation

The function 'make_triangle()' is the most useful because it directly addresses the problem of drawing a triangle, which is the main task. The other functions either change color or perform unrelated actions.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT a command you can give to Tracy?

color

turn

backward

left

Answer explanation

The command 'color' is not a valid command for Tracy, while 'turn', 'backward', and 'left' are all commands that can be given to her. Therefore, 'color' is the correct answer.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the statements below is true about indentation in Python?

A. Indentation only matters in for loops. Then, everything must be indented one level.

B. Indentation never matters in Python. You can align your code any way you like, but indentation makes your code easier to read.

C. Indentation always matters in Python. Every statement must be aligned correctly.

D. Indentation only matters in functions. Then, everything must be indented one level.

Answer explanation

C is correct because indentation is crucial in Python. It defines the structure and flow of the code, indicating which statements belong to which blocks, such as loops and functions. Incorrect indentation will lead to errors.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?