wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Assessment #2

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
2.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
3.
Each item in a list has an "address" or index. The first index in a Python list is what?
a)
0
b)
1
c)
a
d)
A
4.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
5.

Python accepts single ('), double (") and triple (''' or """) quotes to denote strings. Which of the following is NOT acceptable Python syntax?

a)

print('Hello World')

b)

print("Hello World")

c)

print('Hello World")

d)

print(""'Hello World'"")

6.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

7.

data = "No Way!" The expression len(data) evaluates to:

a)

7

b)

9

c)

8

d)

6

8.

What syntax can you use to insert a line break between strings so that they appear over multiple lines?

a)

\l

b)

/

c)

\\n

d)

\n

9.

Which is the most appropriate data type for: "13th December"

a)

Float

b)

Boolean

c)

Integer

d)

String

10.

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

11.

What will the output be from the following code?

print("3+4")

a)

7

b)

34

c)

3+4

d)

SyntaxError

12.

word = "amazing"

For the given string if we run word[2:5] what does it mean?

a)

It will extract alphabets from index 2 to index 4

b)

It will extract alphabets from index 2 to index 5

c)

It will extract alphabets from position 2 to position 4

d)

It will extract alphabets from position 2 to position 5

13.

Which method is used to convert a given string in Capital letters?

a)

Capital

b)

Upper

c)

ConverttoUpper

d)

Capitalize

14.

Which of the following is not a valid string function?

a)

isalphanumeric

b)

isspace

c)

islower

d)

isalnum

15.

string="HELlo"

What will be the result of string.isupper()?

(a)  

16.

Which of the following mathematical operators can be used to concatenate strings:

a)

*

b)

/

c)

-

d)

+

17.

what is a string?

a)

any numeric value

b)

any float value

c)

any character value

d)

any special symbol value

18.

str1='101'

x=int(str1)

z=x+400

print(z)

a)

101400

b)

x400

c)

501

d)

none of above

19.

fruit1="kiwi"

fruit2="strawberry"

print(len(fruit1))

print(len(fruit2))

a)

kiwi and strawberry

b)

4

10

c)

4 10

d)

410

20.

slicing string X="BOnVoyage"

print X[0:5]

a)

BOnVoy

b)

BOnVo

c)

oyage

d)

bonvo