NEW
Font size
WorksheetsPython Module 1 Quiz
Total questions: 60
Worksheet time: 45mins
print(Hello world!)
What will the output be from the following code?
print "Hello world!"
SyntaxError
Hello world!
"Hello world!"
print(Hello world!)
print(3+4)
print("3+4")
What will the output be from the following code?
print ( 3*4)
34
7
12
3*4
print(3*4+5)
print("3*4+5")
What will the output be from the following code?
print(9/3)
3
3.0
9/3
SyntaxError
print(9/3*2+4-5)
print("Hello" + "world!")
What will the output be from the following code?
print("Hello"+ " " + "world" +" "+ "today")
print("Hello" + 2 + "world")
print("Hello world!" * 2)
print("Hello world!" * 2 * "Hello world!")
print("Hello world!\nHello world!")
Hello world!
print("Hello" + str(2) + "world!")
name = 'Dave'
print (name)
Python is an example of a....
Text-based programming language
low level programming language
language written in java script
Visual-based programming language
2.0
The character that must be at the end of the line for if, while, for etc.
:
;
.
,
Which line number contains an output statement?
1
2
3
4
5
Which line number contains variable assignment?
1
2
3
4
5
What is a list in python?
A collection of variables
A collection of items assigned to a single variable
A statement that cant be changed
A Christmas list
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
Which of these operators means EQUAL TO?
'='
'=>'
'<='
'=='
What sort of loop is this?
Count Controlled
Condition Controlled
Python creator is Guido Van Rossum
True
False
What would be the output?
colors = ["red", "green", "yellow", "blue", "white"]
print (colors[2])
red
green
yellow
blue
Square brackets in an assignment statement will create which type of data structure?
s = [ ]
List
Tuple
Dictionary
String
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "Peter", "Tom"]
nameList[0]
nameList(1)
nameList[1]
nameList{1}
To print a list called fruitList we use ---------
list(print)
fruitList.print()
print(fruitList)
fruitList(print)
Which symbols are used to open and close a tuple?
( )
[ ]
< >
{ }
What is a data type of python dictionary?
dicn
tuple
dict
list
Dictionaries use _________ and keys are separated with _________
{ }, :
( ), :
{ }, ( )
[ ], :
What does .append () do?
To delete the item specified.
To add a new item to a specified position in the list.
To find the index of a specific item.
To add a new item to the end of the list.
What does .insert( ) do?
To find the index of a specific item.
To delete the item specified.
To add a new item to a specified position in the list.
To add a new item to the end of the list.
What would be the output?
list1 = [“apple”, “grape”, “orange”, “watermelon”]
list1.pop(2)
print (list1)
[“apple”, “grape”, “orange”, “watermelon”]
[“grape”, “orange”, “watermelon”]
[“apple”, “orange”, “watermelon”]
[“apple”, “grape”, “watermelon”]
Find the syntax to invert the given list:
list1 = [“apple”, “grape”, “orange”, “watermelon”]
print (0 : 4)
print invert (0 : 3)
print( : : -1)
print ( invert)
Tuples in Python are mutable
True
False
What would be the output?
colors = ("red", "green", "white", "blue")
print (type(colors))
("red", "green", "white", "blue")
<class 'tuple'>
<class 'dict'>
<class 'list'>
What does the following comparison operator “>=” represent in Python programming?
Greater than and equal to
Greater than or equal to
Greater than
Less than or equal to
How many possible values are there for a boolean variable?
1
2
3
Infinite
Choose the correct output of the following code.
for i in range(10,13):
print (i)
10
11
12
13
10
11
12
10
11
10
Choose the correct output of the following code.
for i in range(2):
print (i)
2
0
1
2
0
1
0
Choose the correct output of the following code.
for x in range(10,15,3):
print (x)
10
12
14
10
11
12
13
14
15
10
13
10
13
15
A varible defined inside a function is called
Local variable
Global variable
Which of the following Python code will create a set?
(i) set1=set((0,9,0))
(ii) set1=set([0,2,9])
(iii) set1={}
i
ii
iii
All of the above
