Computer Programming Python Qs

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?

#

If you wanted Tracy to complete her command immediately, which speed value would you use?

0

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? 1 for i in range(3):

0,1,2

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

2,4,6,8

How far does Tracy need to move from the starting position to reach the right side of the canvas?

200 pixels

The following loop draws 3 circles on the screen. If I wanted to alter this loop to draw 10 circles, how many lines would my code be? 1 for i in range(3): 2 circle(25) 3 forward(50)

3 lines

Which lines of the code below will be repeated 4 times? 1 penup() 2 for i in range(4): 3 pendown() 4 circle(25) 5 forward(50) 6 backward(200)

3,4, and 5

What are the dimensions of Tracy's world?

400 x 400 pixels

If Tracy starts at the left edge of the canvas and moves forward 50 pixels, how many times will this code need to be repeated to have Tracy reach the right edge of the canvas?

8 times

What two things must be included in your function definition?

A function name and commands to be performed

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

A triangle

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

As many times as you want

Where does Tracy always start in the grid world?

At the (0,0) coordinate in the middle of the canvas

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.

The setposition() command moves Tracy to a coordinate and:

Does not turn her

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

Each function only contains one command

Tracy always starts facing which direction?

East

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

If Tracy is facing right, which of the following commands can be used to turn her to face up? I. left(90) II. turn(up) III. right(-90) IV. setposition(90)

I and II

Which commands would move Tracy forward 100 pixels? I. forward(100) II. backward(-100) III. forward(-100)

I and II

Which of the following statements are 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 V. It is not possible to have the range value count 6, 12, 18, 24 VI. It is not possible to have the range values count 1, 2, 4, 8, 16

I, III, VI

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

I, only

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.

Which of the following is NOT a reason for loops are useful when writing code?

Loops let us make shapes of multiple sizes

If I use the command right(180), which way will Tracy turn?

She will turn around

Variables allow us to:

Store information to use in our code

When Tracy is facing right, from what location does she start drawing her circle?

The bottom of the circle

If you want three circles to be drawn next to each other, after drawing the first circle, how far would you need to move Tracy before drawing the next circle?

The circle's diameter

What is true of Tracy's color command?

The color name must be in quotation marks

When using the circle() command, what value do we put inside the parentheses?

The radius of the circle

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 an unknown number of times

Why do certain words change color in Python?

To show that they are recognized as key words

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

Tracy skips the commands under the if statement

If Tracy started facing right, which direction would she be facing after we ran the following code? 1 left(90) 2 left(90) 3 right(90)

Up

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?

Yes

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.

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)

Which code 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

How would I tell Tracy to move forward 100 pixels?

forward(100)

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 names below follow all naming rules?

make_square

If you want Tracy to move forward 100 pixels without making a line, what set of commands should you write?

penup() forward(100)

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)

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

How many parameters can we use in each function?

unlimited

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

Hydration of 1-Hexene - Lab Flow

View Set

Network + Transcender Questions (Network Architecture)

View Set

Principles of Exercise: Lesson 6

View Set

chap 11 launchpad, chap 11 quiz, chap 12 quiz, chap 12 launchpad, chap 15 launchpad, chap 16 launchpad, chap 17 launchpad, chap 19 launchpad, chap 42 launchpad, chap 16, 15, 17 quiz, chap 19 quiz, chap 30 quiz, chap 30 self assessment, exam 4, exam 4...

View Set

Peds final (ch 1, 3-7, 13-15, 18-21, 23): part 2 (fixed)

View Set

Ch. 28: Pregnancy and Human Development

View Set

Unit 2 Smartbook Assignments and Activities

View Set