Font size
WorksheetsCS Edexcel Unit 6 Part 6 - String Manipulation
Total questions: 25
Worksheet time: 13mins
What does string concatenation mean in programming?
Splitting strings into parts
Joining strings together
Reversing strings
Encrypting strings
What function finds the length of a string in Python?
(a)
How can you access the third character from the left in a string "This is just a simple string"?
string[2]
string[3]
string[4]
string[5]
What will be the output of the code snippet:
string = "This is just a simple string"
print(string[-4])?
g
r
n
t
i
Which method is used to check if a string is all uppercase in Python?
string.upper()
string.isupper()
string.ifupper()
Which method is used to check if a string is all lowercase in Python?
string.lower()
string.islower()
string.iflower()
Match the following string checks to their purpose
String contains only letters and numbers
isalnum
String contains only letters
isalpha
String contains only numbers
isnum
String's words all start with capitals letters
istitle
String contains only spaces
isspace
What will the method isalpha() return for the string "csuk123"?
True
False
Error
None
Which method is used to convert a string to lowercase in Python?
islower()
iflower()
lower()
Which method is used to convert a string to uppercase in Python?
isupper()
ifupper()
upper()
Match the conversion functions to their purpose
Make the first letter only of the string a capital
capitalise
Make the first letter of each word in a string a capital
title
swap the case of each letter in a string
swapcase
How many white spaces are added when using rjust(15) on a 4-character string?
10
11
12
13
What is the purpose of the .format() method in Python?
To swap the case of a string
To justify a string
To better organize string data on the screen
To center a string
What does the format specifier {0:2d} mean in Python's format function?
Allow for 2 decimal places
Allow for 2 digits in the first column
Allow for 2 characters in a string
Allow for 2 spaces
How does the split() method in Python work?
It combines multiple strings into one
It splits a string into a list based on spaces
It removes all spaces from a string
It converts a string into uppercase
What is the output of the following code:
print("A simple string".split())?
['A simple string']
['A', 'simple', 'string']
['A', 'simple string']
['A simple', 'string']
In the format specifier {0:10}, what does the number 10 represent?
Allow for 10 decimal places
Allow for 10 digits
Allow for 10 characters in a string
Allow for 10 spaces
Which method is used to return a substring from the left of a string in Python?
string[:n]
string[-n:]
string.replace()
string.count()
How can you replace a word in a string using Python?
string.replace("old", "new")
string[:n]
string[-n:]
string.count("char")
What will the output be for the code: print(string[-2:]) if string = "CSUK"?
UK
CS
SU
CSUK
What does the method string[1:3] return if string = "CSUK"?
SU
CS
UK
CSUK
Which method is used to count how many times a character appears in a string in Python?
find()
count()
index()
locate()
What will the output be when using the count() method to count the letter "s" in the string "csuk is great!"?
1
2
3
4
Which method is used to find the location of a character in a string in Python?
locate()
find()
search()
index()
What will the output be when using the find() method to locate the letter "k" in the string "csuk is great!"?
5
6
7
8
