computer science quiz

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which comparison operator means 'is not equal to'?

!=

What punctuation is needed to begin a multi-line comment?

"""

What symbol is used at the beginning of an in-line comment?

#

Which program below includes no errors?

# Draw a square for i in range(4): left(90) forward(90)

Suppose you want to make Tracy draw a mountain range, like the one shown below, starting from the left side.

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

What is the default starting value of i in a for loop?

0

What will the values of i be at each iteration of the loop below? for i in range(3):

0, 1, 2

What would be the radius of the circle output from the following code?

10 pixels

What will be the radii of the circles drawn from the following code? for i in range(10, 55, 10): circle(i)

10, 20, 30, 40, 50

What will the values of i be at each iteration of the loop below? for i in range(2, 10, 2):

2, 4, 6, 8

What would be the output of the following command? circle(50,180,3)

3 sides

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

50 spaces

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)

A for loop

What two things must be included in your function definition?

A function name and commands to be performed

Which of the following does the clear command do? A. Clears the screen of any markings left by Tracy B. Turns Tracy to face right C. Sends Tracy to position (0,0)

A only

What shape will be drawn with the following command? circle(50, 360, 3)

A triangle

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

A, C, and F

What will be the output of the following code? count = 5 while count > 0: circle(50) forward(100)

An infinite loop will occur

What will happen when this code is run? radius=20 while radius<50 circle(radius)

An infinite loop will occur.

How many parameters can we use in each function?

As many as we need

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

As many times as you want

Top Down Design makes it easier to solve a problem by:

Breaking the problem down into smaller parts

How is an infinite loop created?

By using a condition that will never become false in a while loop

What is the difference between defining and calling a function?

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.

Which of the following is NOT a way functions make our code more readable?

Each function only contains one command

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 parentheses in a forward or backward command represent?

How far Tracy is supposed to move

Which of the following is an example of an if/else statement scenario?

If it is raining, bring an umbrella. If not, wear sunglasses.

Which of the following statements is true about control structures?

If/else statements can be used inside for loops.

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

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

Variables allow us to:

Store information to use in our programs

What is true of Tracy's color command?

The color name must be in quotation marks

The name color cannot be used for our variable because:

The word color is already used as a Tracy command

Why are parameters useful?

They allow us to tailor functions to be used in multiple situations

Why do we use if statements?

To have Tracy make decisions based on conditional statements

Why do we use while loops?

To repeat code when the number of times to repeat is unknown

If we write an if statement and the condition is false, what does Tracy do?

Tracy skips the commands under the if statement

What will happen when the value of i reaches 5 in the loop below? for i in range(5): left(i) right(90)

Tracy will turn 90 degrees to the right

What will be the output of the following program? for i in range(3, 7, 2): circle(50, 360, i)

Two shapes- a triangle (3 sides) and a pentagon (5 sides).

Which of the following is NOT an example of using Top Down Design?

Using descriptive names for variables

Comments are:

Written for humans to read and understand

Can a user's input control the size of a circle? If so, how?

Yes radius = int(input("Radius: ")) circle(radius)

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 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)

backward(10)

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

backward(201)

What is the correct way to draw a circle that is filled in?

begin_fill() circle(20) end_fill()

How would I change Tracy's trail to a yellow line with a thickness of 10 pixels?

color("yellow") pensize(10)

What is the most effective way to draw three circles in a row of different colors?

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")

Which of the following functions is defined correctly?

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

What is the best way to write a program that uses parameters to draw a square with sides that are 50 pixels long?

def make_square(length): for i in range(4): forward(50) left(90) make_square(length)

Which program will have Tracy move forward 10, then turn left and move forward 20?

distance = 10 forward(distance) left(90) distance = distance * 2 forward(distance)

If I am creating a function that is going to draw 2 squares, which of the following would be the best name option?

draw_squares

Which of the following commands can NOT be used to draw one square?

for i in range(4): circle(50, 360, 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.

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

What would be the output of the following command?circle(50,360,5)

hexogon

How would we write an if statement where Tracy will put the pen down if a variable called count was positive?

if count > 0: pendown()

Which of the following if/else statements using a variable called 'count' are written correctly?

if count > 10: forward(100) else: forward(50)

Which of the names below follow all naming rules?

make_square

How can we use variable to control the size of a circle?

radius = 50 circle(radius)

How would I collect a number from the user to use for the radius of a circle?

radius = int(input("What is the radius?: "))

Which of the following commands can be used to turn Tracy to face North if she is initially facing South?

right(180)

What will be the output of the code below? penup() backward(150) for i in range(10, 50 ,10): forward(i * 2) pendown() circle(i) penup()

small to big 4 circles

Which of the following programs would produce this output? (little squares inside the big square)

square_length = 20 for i in range(4): for i in range(4): forward(square_length) left(90) square_length = square_length * 2

What would be the output of the following code?

stating from bottom left squares increasing

Which is the proper way to call the function three_circles?

three_circles()

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

turn

What is the limit of conditions that can be used in an if/else statement?

unlimited

What is the correct way to ask a user for a color and store the answer as a variable?

user_color = input("Give a color: ")


Kaugnay na mga set ng pag-aaral

Understanding Architecture Midterm

View Set

Psychology Exam 3 Practice Questions

View Set

Ch 2. Chemical Level of Organization - Dr. Deva Joseph

View Set

Testbank Questions: Programming for End Users

View Set

Chapter 15: Absolutism and Constitutionalism Study Guide

View Set

أسئلة الفصل الثالث - أكمل

View Set

Chapter 17 - Finance: Pre-Approval Through Loan Commitment

View Set

Stages of Sleep and Brain Mechanisms

View Set