def add(x, y):
return(x + y)
add(8, 9) #what will happen?
The add(x, y) function will take x and y as inputs and return the sum of them.
The answer is 17.
def sunny_day():
print("It is sunny today!")
sunny_day()
Yes!
The data type of this value:
10
What is an integer?
Converts "90" to 90.
What is the int() function?
What is CS + X?
def add_10(x):
return(x + 10)
add_10(13)
The function, add_10(x), will take x as an input, then return the sum of it and 10.
The answer is 23.
def multiply_by_2():
print(x * 2)
multiply_by_2()
No; we call a variable x in the function, but we never defined it. This is a Name Error.
The data type of this value:
10.9
What is a float?
Takes the number 3.1415 and converts it to 3.
What is the int() function?
The name of your instructor.
Who is Soha?
x = 10
y = 2
if x % y == 0:
print(str(x) + "is divisible by" + str(y))
The computer will check if the variable, x, is divisible by the variable y. If the modulo is 0, then the computer will print out "x is divisible by y". In this case, x = 10 and y = 2, so the computer will print out "10 is divisible by 2".
The error I would trigger if I did not indent the code after my if-statement.
What is an indentation error?
The data type of this value:
'8.9'
What is a string?
True or False: We can use the def keyword to create functions and assign variables to values.
False; we use the def keyword only to create functions, NOT to assign variables to values.
The names of your tutor and class assistants.
Who are Rusha, Hannah, and Dhivya?
weather = 'rainy'
if weather == 'sunny':
print("It's warm today!")
else:
print("Bring an umbrella today!")
The computer will check if the variable, weather, is assigned to the value 'sunny'. If it is, then it will print out "It's warm today!". If it is false, it will print out "Bring an umbrella today!". Since the statement is false, it will print out "Bring an umbrella today!"
def cool_function():
print("The cool function")
cooler_function()
def cooler_function():
print("The cooler function")
Yes!
The data type of this value:
[1, 2, 3, 4, 5]
Takes the string "hello world" and converts it to ['h','e','l','l','o','w','o','r','l','d']
What is list()?
The names of your RCs.
Who are Cheyanne and Rafael?
for i in color:
print(i + i)
def list_tech(lst):
print(lst[-7])
my_list = ["hi", "bye", "yo", "'sup", "later", "whattup"]
list_tech(my_list)
No; this will lead us to an Index out of Range error because my_list does not have an index of -7.
The data type of this value:
10 == 15
What is a boolean?
Allows us to create a collection of numbers.
What is range()?
An item that was NOT included in your packing list:
A: Cleaning products
B: Umbrella
C: Lock
What are cleaning products?