Computer Science Review (Intro)

Ace your homework & exams now with Quizwiz!

Suppose you want to make Tracy draw a mountain range, like the one shown below, starting from the left side. 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():

In the following for loop, how may spaces has Tracy moved when it is complete? for i in range(5): forward(10)

50 spaces

Choose the option that correctly fills in the blanks A and B for the following piece of code. When completed, the for loop should draw a zig zag by repeating 5 times. Inside of the loop, Tracy needs to turn left, move forward, turn right, and move forward. # Makes Tracy draw a zig zag left(15) for i in __A___ : forward(50) left(135) __B___(50) right(135)

A) range(5) B) forward

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

As many times as you want

What is the difference between declaring and calling a function?

Declaring a function means you are creating the definition of the function. Calling a function means you are using the function in your program.

def mystery_function(): for i in range(10): color("green") forward(100)

Draws a green line that is longer than 100 units long.

What does this piece of code do? backward(100) right(90) backward(100) right(90) backward(100) right(90) backward(100) right(90)

Draws a square moving backwards

Which of the following is NOT a purpose of using functions?

Functions let you execute code a fixed number of times.

What does the number in the parenthesis in a forward or backward command represent?

How far Tracy is supposed to move

Which of the following statements is true about for loops? I. By default, the range function starts at 0 II. Using for i in range(4) will result in i taking the values 0, 1, 2, 3, 4 III. For loops let you repeat something any number of times IV. Statements in a for loop do not need to be indented

I, III

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

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

Suppose we want Tracy the Turtle to move forward 100. What is wrong with the following statement: forward = 100

The 100 should be in parentheses, and there shouldn't be a equal sign.

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

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

Which of the following statements correctly changes Tracy's color to blue?

color("blue")

Which of the following choices draws a straight multicolor line?

color("red") forward(40) color("blue") forward(40) color("green") forward(40)

What keyword means that you are defining a function?

def

Which of the following functions is declared correctly?

def draw_edge(): forward(100) left(90)

Which of the following choices is a correct way to write a for loop in Python?

for i in range(10): # loop body code

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

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

Which of the following is NOT a turtle command?

turn


Related study sets

BF LS Chapter 11: Risk and Return

View Set

Chapter 8 relevant fitness and wellness issues

View Set

Industrial Safety OSHA 10 Pretest Quizlet

View Set

voting and politcal participation

View Set

3- Life Insurance Policies- Provisions, Options, and Riders

View Set