NEW
Font size
WorksheetsPython - CDT
Total questions: 20
Worksheet time: 12mins
print("3+4")
Print("Hello world!")
print(Hello world!)
print("Hello world!" * 2)
print(9/3)
people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
Which symbols are used to open and close a list?
( ) round brackets
( ) curly brackets
[ ] square brackets
" " speech marks
Which of these assigns a list to a variable?
fruit = input(["apples", "oranges", "bananas"])
fruit = ["apples", "oranges", "bananas"]
fruit == ["apples", "oranges", "bananas"]
fruit["apples", "oranges", "bananas"]
Which of these assigns a list to a variable?
fruit = input(["apples", "oranges", "bananas"])
fruit = ["apples", "oranges", "bananas"]
fruit == ["apples", "oranges", "bananas"]
fruit["apples", "oranges", "bananas"]
What will be the output of the following code :
print type(type(int))
type 'int'
type 'type'
Error
0
fruit1="kiwi"
fruit2="strawberry"
print(len(fruit1))
print(len(fruit2))
kiwi and strawberry
4
10
4 10
410
index of a string begins with
1
0
a
-1
What command is used to shuffle a list ‘L’?
L.shuffle()
random.shufflelist(L)
shuffle(L)
random.shuffle(L)
What is the output of the following program?
language = ['P', 'y', 't', 'h', 'o', 'n']
print(language[:-4])
['t']
['P','y']
['P','y','t']
['t','h','o','n']
Suppose a tuple test contains 5 elements. How can you set the 3rd element of the tuple to ‘Python’?
test[2] = 'Python'
test[3] = 'Python'
test(2) = 'Python'
Elements of tuple cannot be changed
What is the output of the following code?
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
0 1 2 3 0
0 1 2 0
0 1 2
Error
