What data type is the following value:
"password123!"
string
What is the mathematical operator for an exponent?
**
What will the following line of code print to the console?
print("Hello", "there" + "!")
Hello there!
What punctuation follows all calls to functions?
Parentheses ()
Fill in the blank of the following code, written to calculate the area of a circle:
area = _________* r **2
math.pi
What data type would be best for representing the price of gas?
float
What does modulus mean?
What is the difference between + and , in a print statement?
+'s leave no space, commas leave a space
Write a line of code that will allow the user to input their name, and store it in a variable called name.
name = input("What is your name?")
Write a line of code that would store a random number between 5 and 10 (inclusive) in a variable called x. You may assume that the random module has already been imported.
x = random.randint(5, 10)
What is the problem with the following code?
current_gen = 18
print("iPhone " + current_gen)
You cannot use a + to combine a string and an integer.
What is the difference between / and //?
Regular division (float answer) vs integer division (integer answer)
What symbol is used to concatenate two strings?
+
Observe the following line of code:
age = int(input("What is your age?"))
What is the purpose of int()?
input() normally reads in a string. int() will save the data as an integer.
In order to use anything from the math module, what must you first write at the top of your code?
import math
What value would the code below produce?
str(5.6)
"5.6"
What is the value of x after the following lines of code?
x = 2
x += 4
x /= 2
What does the additional argument end= replace?
The default new line at the end of a printed statement.
What do we call the values inside of the parentheses of a function?
Arguments
Look at the following attempted variable name:
2nd option!
What are three reasons why this variable name is invalid?
The space, the "!", and the leading number.
What value would the code below produce?
int("5.6")
Error
What is the value of x after the following lines of code?
x = 3
x *= 2
x += (40 - x**2)
x = x % 3
x = 1
What will the following print?
print("Hip", "Hip", "Hooray", sep="! ")
Hip! Hip! Hooray
dogs = input("How many dogs?")
cats = input("How many cats?")
print("There are", dogs+cats, "animals.")
Susan runs her program above, inputting 1 (for dogs) and then 3 (for cats). What will print to the console?
There are 13 animals.
What does the following evaluate to?
abs(3 - math.sqrt(36)) + 8 // 3