Font size
WorksheetsCPT C04 String functions
Total questions: 16
Worksheet time: 16mins
string="computing"
print(string[-3:])
What is the output?
(a)
string="computing"
The output of the program is COMPUTING.
What is the missing code (one line only)?
(a)
string="Computing Computing"
print(string.strip())
What is the output?
(a)
greeting="Hello, Computing!."
print(greeting.strip(" .,H"))
What is the output?
(a)
greeting="Computing Computing"
print(greeting.find("p",4))
What is the output?
(a)
greeting="Computing Computing"
print(greeting.find("m"))
(a)
greeting="Computing Computing"
print(greeting.find("k"))
(a)
greeting="Hello, Computing!."
print(greeting.strip("el.,H"))
(a)
my_school=["Pei","Hwa","Secondary","School"]
(a)
print(my_school)
Output: Pei Hwa Secondary School
What is the missing code?
my_dict={"School":"PH", "Area":"Sengkang"}
my_dict=" at ".join(my_dict.keys())
print(my_dict)
(a)
my_dict={"School":"PH", "Area":"Sengkang"}
my_dict=" at ".join(my_dict.values())
print(my_dict)
What is the output?
(a)
State the function to convert an ASCII code to character.
(a)
State the function to convert a character to an ASCII code.
(a)
words = "red-blue-green-yellow"
print(words.split("-"))
What is the output?
(a)
greeting = 'apple,orange,banana,grape'
print(greeting.split(',', 2))
(a)
sentence = 'one--two----three'
print(sentence.split('--'))
(a)
