coding summary of tracey

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

How can we use variable to control the size of a circle? 1)radius = 50 circle(radius) 2)radius = circle(50) 3)circle(radius) radius = 50 4)radius = 50 circle(50)

1

Which of the following commands can be used to turn Tracy to face North if she is initially facing South? 1)left(90) right(90) 2)right(180) 3)right(90) left(180) 4)left(360)

2

In which of the following situations would it be best to make a function? 1)You want Tracy to draw a blue line, and your program requires lots of blue lines. 2)You need Tracy to move forward by 100. 3)You need Tracy to turn right and then turn left. 4)You need to change Tracy's color.

1

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? 1)# Has Tracy draw a single triangle def make_triangle(): 2)# Change's Tracy's color to red def change_to_red(): 3)# Moves Tracy forward by 100 def move_100(): 4)# Draws a square def my_function():

1

What is the difference between defining and calling a function? 1)Defining a function means you are teaching the computer a new word. Calling a function means you are commanding the computer to complete defined actions. 2)There is no difference. 3)Calling a function means you are teaching the computer a new word. Defining a function means you are commanding the computer to complete defined actions. 4)Defining a function must be done each time you want to use the function. Calling a function can only happen once in your code.

1

What will be the radii of the circles drawn from the following code? for i in range(10, 55, 10): circle(i) 1)10, 20, 30, 40, 50 2)10, 15, 20, 25, 30, 35, 40, 45, 50, 55 3)10, 55, 10 4)10, 20, 30, 40, 50, 55

1

When the following for loop is complete, how many spaces will Tracy have moved? for i in range(5): forward(10) 1)50 spaces 2)60 spaces 3)10 spaces 4)5 spaces

1

Which of the following functions is declared correctly? 1)def draw_edge(): forward(100) left(90) 2)def draw_edge(): forward(100) left(90) 3)def draw_edge forward(100) left(90) 4)def draw_edge(){ forward(100) left(90) }

1

Which of the following statements are true about for loops? A. By default, the range function starts at 0 B. Using for i in range(4) will result in i taking the values 0, 1, 2, 3, 4 C. For loops let you repeat something any number of times D. Statements in a for loop do not need to be indented E. It is not possible to have the range value count 6, 12, 18, 24 F. It is not possible to have the range values count 1, 2, 4, 8, 16 1)A, C, and F 2)A, B, C, and F 3)A, B, C, E, and F 4)A and C

1

Which command will Tracy perform when given the following code? count = 5 count = count * 2 if count < 10: forward(count) elif count < 20: backward(count) else: circle(count) 1)forward(10) 2)backward(10) 3)backward(10) circle(10) 4)circle(10)

2

Which of the following is NOT a command you can give to Tracy? 1)color 2)turn 3)backward 4)left

2

Can a user's input control the size of a circle? If so, how? 1)No, user input is a string. 2)Yes circle(user_input=50) 3)Yes radius = int(input("Radius: ")) circle(radius) 4)Yes radius = input("Radius: ") circle(radius)

3

What control structure would be best to use in the following code? backward(100) right(90) backward(100) right(90) backward(100) right(90) backward(100) right(90) 1)A function 2)A while loop 3)A for loop 4)An if/else statement

3

What is the most effective way to draw three circles in a row of different colors? 1)for i in range(3): circle(50) penup() forward(100) pendown() color("red") 2)def draw_circle(color_choice): pendown() begin_fill() circle(50) end_fill() penup() forward(50) color("red") draw_circle() color("blue") draw_circle() color("yellow") draw_circle() 3)def draw_circle(color_choice): pendown() color(color_choice) begin_fill() circle(50) end_fill() penup() forward(100) draw_circle("red") draw_circle("blue") draw_circle("yellow") 4)def draw_circle(color_choice): pendown() color(color_choice) begin_fill() circle(50) end_fill() penup() forward(50) draw_circle("red") draw_circle("blue") draw_circle("yellow")

3

What shape will be drawn with the following command? circle(50, 360, 3) 1)A circle 2)A hexagon 3)A triangle 4)A diamond

3

Which of the following is NOT a purpose of using functions? 1)Functions let Tracy do new things. 2)Functions help group statements together to make your code more readable. 3)Functions let you execute code a fixed number of times. 4)Functions allow the programmer to reuse code.

3

Which of the statements below is true about indentation in Python? 1)Indentation only matters in for loops. Then, everything must be indented one level. 2)Indentation never matters in Python. You can align your code any way you like, but indentation makes your code easier to read. 3)Indentation always matters in Python. Every statement must be aligned correctly. 4)Indentation only matters in functions. Then, everything must be indented one level.

3

Which program below includes no errors? 1)# Draw a square # for i in range(4): left(90) forward(40) 2)# Draw a square def draw square: for i in range(4): left(90) forward(90) 3)# Draw a square for i in range(4): left(90) forward(90) 4)# Draw a square def draw square(): for i in range(4): left(90) forward(90)

3

Suppose you write a function. How many times can you call the function in your code? 1)Once 2)Not more than the number of commands the function holds 3)It depends on the function 4)As many times as you want

4

What does the number in the parentheses in a forward or backward command represent? 1)How many degrees Tracy is supposed to turn 2)How fast Tracy is supposed to move 3)How many times Tracy should repeat the command 4)How far Tracy is supposed to move

4

What will be the output of the following code? count = 5 while count > 0: circle(50) forward(100) 1)5 circles in a row 2)4 circles in a row 3)A slinky with 5 circles 4)An infinite loop will occur

4

What will be the output of the following program? for i in range(3, 7, 2): circle(50, 360, i) 1)Three circles with radii of 3, 7 and 2. 2)Three shapes- a triangle (3 sides), a heptagon (7 sides), and a line (2 sides). 3)Three shapes- a triangle (3 sides), a pentagon (5 sides), and a heptagon (7 sides). 4)Two shapes- a triangle (3 sides) and a pentagon (5 sides)

4

Which command will Tracy perform when given the following code? count = 200 count = count + 1 if count % 2 == 0: forward(count) backward(count) 1)forward(200) 2)backward(200) 3)forward(201) 4)backward(201)

4

Which of the following commands can NOT be used to draw one square? 1)forward(50) left(90) forward(50) left(90) forward(50) left(90) forward(50) left(90) 2)for i in range(4): forward(50) left(90) 3)circle(50, 360, 4) 4)for i in range(4): circle(50, 360, 4)

4

Which of the following pieces of code will make Tracy do the following actions three times: go forward, change colors, and then turn around. 1)for i in range(4): forward(30) color("blue") left(180) 2)for i in range(3): forward(30) color("blue") left(180) color("red") 3)for i in range(3): backward(30) color("blue") left(180) 4)forward(30) color("blue") left(180) forward(30) color("green") left(180) forward(30) color("orange") left(180)

4


Ensembles d'études connexes

NTDT200 Chapter 3 Summative Quiz

View Set

Standards of Measurement and SI Units

View Set

MORT 234 chapter 11.1 Brief Hypotheticals

View Set

Global Climate Change Final Exam

View Set

environmental ch.3 reading quiz, mes, and video questions

View Set

Práctica: 2-Clarificar (Clarify each sentence with a prepositional phrase) 3.2 p.93

View Set