wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS Edexcel Unit 6 Part 6 - String Manipulation

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What does string concatenation mean in programming?

a)

Splitting strings into parts

b)

Joining strings together

c)

Reversing strings

d)

Encrypting strings

2.

What function finds the length of a string in Python?

(a)  

3.

How can you access the third character from the left in a string "This is just a simple string"?

a)

string[2]

b)

string[3]

c)

string[4]

d)

string[5]

4.

What will be the output of the code snippet:

string = "This is just a simple string"

print(string[-4])?

a)

g

b)

r

c)

n

d)

t

e)

i

5.

Which method is used to check if a string is all uppercase in Python?

a)

string.upper()

b)

string.isupper()

c)

string.ifupper()

6.

Which method is used to check if a string is all lowercase in Python?

a)

string.lower()

b)

string.islower()

c)

string.iflower()

7.

Match the following string checks to their purpose

a)

String contains only letters and numbers

1.

isalnum

b)

String contains only letters

2.

isalpha

c)

String contains only numbers

3.

isnum

d)

String's words all start with capitals letters

4.

istitle

e)

String contains only spaces

5.

isspace

8.

What will the method isalpha() return for the string "csuk123"?

a)

True

b)

False

c)

Error

d)

None

9.

Which method is used to convert a string to lowercase in Python?

a)

islower()

b)

iflower()

c)

lower()

10.

Which method is used to convert a string to uppercase in Python?

a)

isupper()

b)

ifupper()

c)

upper()

11.

Match the conversion functions to their purpose

a)

Make the first letter only of the string a capital

1.

capitalise

b)

Make the first letter of each word in a string a capital

2.

title

c)

swap the case of each letter in a string

3.

swapcase

12.

How many white spaces are added when using rjust(15) on a 4-character string?

a)

10

b)

11

c)

12

d)

13

13.

What is the purpose of the .format() method in Python?

a)

To swap the case of a string

b)

To justify a string

c)

To better organize string data on the screen

d)

To center a string

14.

What does the format specifier {0:2d} mean in Python's format function?

a)

Allow for 2 decimal places

b)

Allow for 2 digits in the first column

c)

Allow for 2 characters in a string

d)

Allow for 2 spaces

15.

How does the split() method in Python work?

a)

It combines multiple strings into one

b)

It splits a string into a list based on spaces

c)

It removes all spaces from a string

d)

It converts a string into uppercase

16.

What is the output of the following code:

print("A simple string".split())?

a)

['A simple string']

b)

['A', 'simple', 'string']

c)

['A', 'simple string']

d)

['A simple', 'string']

17.

In the format specifier {0:10}, what does the number 10 represent?

a)

Allow for 10 decimal places

b)

Allow for 10 digits

c)

Allow for 10 characters in a string

d)

Allow for 10 spaces

18.

Which method is used to return a substring from the left of a string in Python?

a)

string[:n]

b)

string[-n:]

c)

string.replace()

d)

string.count()

19.

How can you replace a word in a string using Python?

a)

string.replace("old", "new")

b)

string[:n]

c)

string[-n:]

d)

string.count("char")

20.

What will the output be for the code: print(string[-2:]) if string = "CSUK"?

a)

UK

b)

CS

c)

SU

d)

CSUK

21.

What does the method string[1:3] return if string = "CSUK"?

a)

SU

b)

CS

c)

UK

d)

CSUK

22.

Which method is used to count how many times a character appears in a string in Python?

a)

find()

b)

count()

c)

index()

d)

locate()

23.

What will the output be when using the count() method to count the letter "s" in the string "csuk is great!"?

a)

1

b)

2

c)

3

d)

4

24.

Which method is used to find the location of a character in a string in Python?

a)

locate()

b)

find()

c)

search()

d)

index()

25.

What will the output be when using the find() method to locate the letter "k" in the string "csuk is great!"?

a)

5

b)

6

c)

7

d)

8