Definitions, Keywords, and Prior Knowledge
Graphics
Functions
Logic and Booleans
Trivia! (HARD)
100

What is the keyword needed to create a function?

def

100

What is the top left coordinate in the Python Canvas? 

0,0

100

Why do we write functions?  (3 correct answers!  Most correct gets the points!)

Make code easier to understand by giving a group of instructions a single name

Avoid writing repeated code

Make code reusable

100

What can a Boolean variable contain? 

True or FAlse

100

Which two months of the year are named for mortal men?

July and August

200

What are the possible values of x given the following code (write all answers out): 

x = random.randint(5, 8)

5, 6, 7, 8

200

The below code does not add a shape to our canvas.  Why? 

def draw_rect(x,y):
    rect = Rectangle(20, 50)
    rect.set_position(x,y)

Missing the add() method. 

200

What is the difference between a parameter and an argument? 

A parameter is in the () of a function header line as it is being defined.  An argument is in the () when a function is called.  

The value of an argument is passed to the parameters.

200

A and B are booleans. 

A = True
B = False

What is the value of this statement? 

(not A or B) and A

False

not A is the opposite of True = False
(not A or B) is False or False = False
(not A or B) and A is False and True = False 

200

What is the metric unit, consisting of 10,000 square meters, that is the primary measure of land in most countries?

Hectare

300

What does API stand for? 

Application Programming Interface

300

In the method set_position(a, b), what does b represent? 

The y position of the object

300

What is the minimum and maximum number of return values that can ever come out of a function? 

Min: 0

Max: 1

A function may return nothing at all, or it may return a single value.  Even if there are multiple return STATEMENTS, there will only ever be one return value. 

300

What is the name of the error when we divide by 0? 

A ZeroDivisionError

300

What technology company was founded in 1993 with the vision that the next wave of computing would be graphics-based? The company took its name from the Latin word for "envy" and features product families GeForce, Quadro, and Tegra.

Nvidia

400

If n%2==0, what can you say about n? 

n is even

400

What is the return value of the following function: 

def draw_rectangle(width, height, color):
    rect = Rectangle(width, height)
    rect.set_color( color )
    rect.set_position( 0, 0)
    add(rect)

This function has no return value since we do not have a return statement. 
400

What happens if we try to print a function that has no return value? 

"None" is printed

400

A firetruck is red and noisy.  

Write a function is_firetruck that takes in two parameters, is_red and is_quiet and returns True if it is a firetruck! 

def is_firetruck(is_red, is_quiet):
    return ( is_red and not is_quiet)

400

Deglutition is the scientific term for what common bodily function that humans do hundreds of times a day?

Swallowing

500

What keywords are used to handle exceptions in Python? 

try 

except

500

We want to position a circle on a canvas so it is fully displayed with no parts being cut off.  

The radius of the circle is 40, the width of the Canvas is 400, and the height of the Canvas is 480. 

What is the min and max values of the center's x-coordinate?  What is the min and max value of the center's y-coordinate?

Min X: 40
Max X: 360

Min Y: 40
Max Y: 440

500

What is the difference between "namespace" and "scope"?

"namespace" is the collection of available variables at a certain point in your code. 

"scope" is the lines of code that a variable exists.

500

What is the EXACT cause of a ValueError as discussed in class? 

A ValueError happens when we try to cast a non-integer string input as a int. 

500

In what country was Haagen-Dazs ice cream developed?

In what country was Haagen-Dazs ice cream developed?

M
e
n
u