What will this return:
(not True) or (not False)
True
a = "You’re a wizard Harry"
print(a[9:])
What will this print?
wizard Harry
thislist = ["apple", "banana", "cherry"]
print(thislist[1])
banana
What is the format of an if-else statement?
if <expression>:
<suite>
elif <expression>:
<suite>
else:
<suite>
What do you use to create multiline strings?
Three quotations
What will this return:
(False or (not False)) and True
True
To concatenate, or combine, two strings you can use the + operator.
a = "Hello"
b = "World"
c = a + b
print(c)
HelloWorld
thislist = ["apple", "banana", "cherry"]
print(thislist[-1])
cherry
What is the format of a while loop?
while <expression>:
<suite>
What keyword do you use to return something within a function?
return
Which boolean operator evaluates a and b, True if a is equal to b, else False
==
a = "Harry Potter"
print(len(a))
12
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[:4])
["apple", "banana", "cherry", "orange"]
What is the format of a for-loop?
for i in <expression>:
<suite>
What keyword do you use to define a function?
def
What will this return: False or True and False
False
What function do you use to concatenate strings?
+
thislist = ["apple", "banana", "cherry"]
thislist[1] = "blackcurrant"
print(thislist)
["apple", "blackcurrant", "cherry"]
How do you get user input?
input()
What boolean operator do you use to check if an item is in a list?
in
Which boolean operator does the following:
Evaluate the subexpression <left>.
If the result is a true value v, then the expression evaluates to v.
Otherwise, the expression evaluates to the value of the subexpression <right>.
When slicing strings, does the start index always have to be smaller than the end index?
Yes
What functions do you use to add items to a list?
insert, append
What does the word break do to a loop?
ends
What is the boolean operator to check if things are not equal?
!=
not and ==