wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python - CDT

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
2.
What will the output be from the following code?
Print("Hello world!")
a)
NameError
b)
Hello world!
c)
"Hello world"
d)
Print(Hello world!)
3.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
4.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2
5.
What will the output be from the following code?
print(9/3)
a)
3
b)
3.0
c)
9/3
d)
SyntaxError
6.
Which function takes a users input
a)
print()
b)
int()
c)
input()
d)
def
7.
A data type consisting of numbers, letters and symbols.
a)
String
b)
Integer
c)
Float
d)
Boolean
8.
Which is the most appropriate data type for: "13th December"
a)
Float
b)
Boolean
c)
Integer
d)
String
9.
A location in memory used to store data that can be changed.
a)
Constant
b)
Value
c)
Variable
d)
Iteration
10.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
11.

Which symbols are used to open and close a list?

a)

( ) round brackets

b)

( ) curly brackets

c)

[ ] square brackets

d)

" " speech marks

12.

Which of these assigns a list to a variable?

a)

fruit = input(["apples", "oranges", "bananas"])

b)

fruit = ["apples", "oranges", "bananas"]

c)

fruit == ["apples", "oranges", "bananas"]

d)

fruit["apples", "oranges", "bananas"]

13.

Which of these assigns a list to a variable?

a)

fruit = input(["apples", "oranges", "bananas"])

b)

fruit = ["apples", "oranges", "bananas"]

c)

fruit == ["apples", "oranges", "bananas"]

d)

fruit["apples", "oranges", "bananas"]

14.

What will be the output of the following code :


print type(type(int))

a)

type 'int'

b)

type 'type'

c)

Error

d)

0

15.

fruit1="kiwi"

fruit2="strawberry"

print(len(fruit1))

print(len(fruit2))

a)

kiwi and strawberry

b)

4

10

c)

4 10

d)

410

16.

index of a string begins with

a)

1

b)

0

c)

a

d)

-1

17.

What command is used to shuffle a list ‘L’?

a)

L.shuffle()

b)

random.shufflelist(L)

c)

shuffle(L)

d)

random.shuffle(L)

18.

What is the output of the following program?

language = ['P', 'y', 't', 'h', 'o', 'n']

print(language[:-4])

a)

['t']

b)

['P','y']

c)

['P','y','t']

d)

['t','h','o','n']

19.

Suppose a tuple test contains 5 elements. How can you set the 3rd element of the tuple to ‘Python’?

a)

test[2] = 'Python'

b)

test[3] = 'Python'

c)

test(2) = 'Python'

d)

Elements of tuple cannot be changed

20.

What is the output of the following code?

i = 0

while i < 3:

print(i)

i += 1

else:

print(0)

a)

0 1 2 3 0

b)

0 1 2 0

c)

0 1 2

d)

Error