x = "Hello "
y = "World"
print(x + y)
What would be printed?
What, when inputed into bool(), would result in false? (be specific)
Numerical 0 (0 or 0.0, not '0' or "0.0")
Which of the following is NOT true?
It is necessary to use "else" whenever "if" is used in a program
All statements in a block have the same indent
An indented block should be started after the : symbol
All statements are true.
It is necessary to use "else" whenever "if" is used in a program
What is a python function?
A piece of code that only runs when called
What is the order of operations of the boolean statements?
NOT, AND, OR
income = 1000
if income > 2000:
tax = 500
else:
tax = 0
print(tax)
0
What is the order of conditional statements?
If- Elif- Else
Which of the following is true?
9%2 = 4
9 // 2 = 4
9/2 = 4
None of the above.
9 // 2 = 4
Which of the following ways are valid ways of dividing the variable x by 2?
x/2
x = x/2
x_new = x/2
x/=2
All but x/2
How would you fix the code below?
print('I'm very excited about my exam!')
backslash (escape character) before the '
print('I\'m very excited about my exam!')
for char in "Hello":
print(char, end = ",")
H,e,l,l,o
Where does python start counting from?
0
Which ones are true?
The variable names cannot start with a digit.
Variable names are case-sensitive.
Variables cannot start with an underscore
Variable names can be reserved keywords.
The variable names cannot start with a digit.
Variable names are case-sensitive.
The list.pop() function will
Remove the last element from a list
What would the output of the following code be?
second_list_loop = -1
for i in range(5):
second_list = [1,2,3,4,5]
print(i, second_list[second_list_loop])
second_list_loop -=1
0, 5
1, 4
2, 3
3, 2
4, 1
lst = [1, 2, 3, 4, 5]
del lst[:]
print(lst)
[]
How is the structure of a conditional statement similar to the structure of a recursive statement and a function definition?
<keyword> ___ :
<stuff having to do with the thing>
Which is true?
List object can contain a tuple as one of the items
Tuple can contain a list as one of the items
Both are true
Both are false
Both are true
Differentiate between a break and continue statement
A break statement terminates the loop it is in, the continue statement skips the current iteration and starts the next one.
What would this output?
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(my_list[-3:-1])
del my_list[7:9]
print(my_list[-3:-1])
del my_list[::]
print(my_list)
[8,9]
[6,7]
[]
from math import sin
print(sin(1))
0.8414709848078965
A number
If lst = [[1,2] , [3,4]] , which of the following result true?
3 in lst
[3,4] not in lst
3 in lst[1]
None of the above
3 in lst[1]
Which of the following would Python actually run?
if age >= 18
if age = 18
if age >=18:
if age >=18:
Are the two pieces of code below equivalent?
i = 0
while i<5:print("The iteration is", i)
i +=1
AND
for i in range(5):print("The iteration is", i)
Yes!