wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

String Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which method can be used to remove any whitespace from both the beginning and the end of a string?

a)

trim()

b)

strip()

c)

len()

d)

replace()

2.

What is a correct syntax to return the first character in a string?

a)

x = "Hello"[0]

b)

x = sub("Hello", 0, 1)

c)

x = "Hello".sub(0, 1)

d)

All of the above

3.

What is the correct syntax to output the type of a variable or object in Python?

a)

print(typeof(x))

b)

print(typeOf(x))

c)

print(type(x))

d)

print(typeof x)

4.

Which one does take you to next line?

a)

\t

b)

\n

c)

\'

5.

Print output.

x=”CHAMPION”

print(x[5])

a)

C

b)

A

c)

I

d)

P

6.

Which method can be used to calculate length of list:

a)

len()

b)

string()

c)

count()

d)

remove()

7.

What in programming language are like something which gets active or gets task done when called

a)

Functions

b)

Set

c)

Tuple

d)

Dictionary

8.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
9.

What is the output of Name = print('Dave")

a)

dave

b)

"Dave"

c)

Syntax Error

d)

Dave

10.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
11.

Find the output of the following code:

>>>str1='Save Soil'

>>>str1.isalnum( )

a)

Save Soil

b)

True

c)

False

12.

Predict the output:

>>>str1="Rajathi Raja"

>>>print(str1.count('Raja'))

a)

1

b)

2

c)

Error

d)

Raja

13.

Find the output of the given Python program?

a = 25

if a < 15:

print("Hi")

if a <= 30:

print("Hello")

else:

print("Know Program")

a)

Hi

b)

Hello

c)

Know Program

d)

Compiled Successfully, No Output.

14.
Stores a piece of data, and gives it a specific name
a)
variable
b)
whitespace
c)
interpreter
d)
modulus
15.

Variable names can start with...

a)

...only capital letters.

b)

...any number, letter or an underscore (_).

c)

...any letter or symbol.

d)

...any letter or an underscore (_).