Font size
Worksheetspython basics
Total questions: 20
Worksheet time: 12mins
x = 5
y = 6
print(x*y)
The code above displays the following:
11
x*y
Syntax Error
30
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
print("Hello world!" * 2)
people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.remove('Tinian')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Tinian', 'Rota']
['Saipan', 'Tinian']
['Saipan', 'Rota']
What is the index of the name 'Paula' in the following list:
names = ["Paul","Phillip","Paula","Phillipa"]
0
1
2
3
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands[0] = 'Guam'
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
Select the correct answer:
x = 15
y = 4
print(x // y)
3
3.75
4
5
One of the lines contains at least one error.
Which line is it?
The program above
prints all the odd numbers between 1 and 20
prints all even numbers between 1 and 20
print all the odd numbers between 1 and 21
prints all the even numbers between 1 and 21
The above program prints
Numbers 1 to 10 in reverse order
Numbers 1 to 11 in reverse order
Numbers 1 to 10
Numbers 1 to 11
The code above prints all numbers between 1 and 30 that are
not divisible by 5
divisible by 5
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
print(nameList.count("John"))
What would be the output
1
2
3
Error
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
How to create a numeric variable age with a value of 10
age = 10
age = int(10)
age = "10"
age = '5'
In the code above, age is a
string
integer
floating point
Which symbol means "not equal to"
%
==
!=
**
What symbol comes before a comment?
$
>>
#
!
