How would you create a blank list and save to variable called myList?
myList = []
This often used statement checks whether a statement is true or false before making a decision.
What is an 'if' statement?
To comment a line in Python, you use this/these character(s).
What is # ?
How would you create a list from the variable word if it contained a string?
myList = list(word)
This flow control statement loops through a set of statements if a test statement continues to evaluate to True, this may continue for an unknown number of times.
What is a while loop?
What is 7%9?
7
Identify the letter printed from these lines of code: words = "GIS Rules!" print words[4]
What is 'R'?
What is the result of this code?
myList = [12,6,5]
myList.append(4)
myList.insert(2,3)
print(myList)
[12, 6, 3, 5, 4]
How would you get a float number inputted from the user and save to variable num?
num = float(input("Please give me a decimal number"))
What is the value of 'x' after the following Python code has completed executing, what is the last value of x printed?
x = 100
for n in range(1,5):
x = x*n
print (x)
What is 2400?
What the output of this code?
number = 15
number * 12
print(number)
15
Identify the letters printed from these lines of code: words = "GIS Rules!" print words[:5]
What is 'GIS R'?
What code would compare the 3rd item in myList to every other item to determine if it was equal and print true every time it was equal?
for x in myList:
if x == myList[2]:
print(true)
Does all the data in a list have to be of the same type?
No
What is output when the following code is run?
n = 0
while n > 0:
n -= 1
print(n)
Nothing the loop never executes
What does the following code do?
x = 9
y = 7
temp = x
x = y
y = temp
Switches the values of x and y
What does the following code output?
word = "funny"
for x in range(len(word)):
print(word[x])
f
u
n
n
y
What does the following code output?
myList = [9,7,2,6,5,1]
for x in range(len(myList)):
if myList[x]%2 == 1:
print(x)
0
1
4
5
This code has an error. What is it missing?
n = 10
while n<100:
print (n)
What is a increment statement. n doesn't change inside the while loop
This built-in Python function returns the length of many objects, including Strings.
What is len()?
Given the following code
name = input("Give me your name")
How would you print out the last letter of the name?
print(name[len(name)-1])