Pre-defined functions are the pieces of programs that come with the software and do a specific task.
Their advantage is that we can use them and re-use them as many times as we need. They are already tested and free of errors.
Returns the integer value representing the length of a string.
Syntax:
LENGTH(<identifier>)
The <identifier> should be of data type string.
Example
Given the string Why did the Oreo go to the dentist?
What is the length of the string?
Answer: 35
How do you get its length using the function LENGTH?
Answer:
LENGTH("Why did the Oreo go to the dentist?")
How does this work in Python?
Answer:
len("Why did the Oreo go to the dentist?")
Returns the string/character with all characters in lower case.
Syntax:
LCASE(<identifier>)
The identifier should be of data type string or char.
Example
Turn the question Why did the Oreo go to the dentist? to lowercase.
Solution:
LCASE("Why did the Oreo go to the dentist?")
This solution will return:
why did the oreo go to the dentist?
Returns the string/character with all characters in upper case.
Syntax:
UCASE(<identifier>)
The identifier should be of data type string or char.
Example
Turn the question Why did the Oreo go to the dentist? to uppercase.
Solution:
UCASE("Why did the Oreo go to the dentist?")
This solution will return:
WHY DID THE OREO GO TO THE DENTIST?
Syntax:
SUBSTRING(<identifier>, <start>, <length>)
Returns a string of length length starting at position start. The identifier should be of data type string, length and start should be positive and of data type integer.
The start position will (generally) be 1 (but can also be zero).
Example
Extract the word Oreo from the string Why did the Oreo go to the dentist?
Solution:
SUBSTRING("Why did the Oreo go to the dentist?", 13, 4)
This solution will return:
Oreo