- Information
- AI Chat
Was this document helpful?
Task 4 String Manipulation - Procedural Pytho
Module: Cambridge Ordinary Level Islamiat (2058)
5 Documents
Students shared 5 documents in this course
University: University of Cambridge
Was this document helpful?
2
ComputerScienceUK.com
CSUK:Teache
r
Computer Science UK Membership Site Licence: Do not share outside of your centre
Introduction
String manipulation is very useful and very widely used in every language. Often,
programmers are required to break down strings and examine them closely. For
example, a password strength checker would have to strip a string down and examine
them closely to see if it contains letters, numbers and/or symbols.
We will now take a look at the various methods of manipulating strings, that are built
into Python. We can perform a great number of useful tasks on strings via these
methods.
Concatenation
Concatenation simply means ‘joining’. We know from before that the ‘+’ operator is
used to add numeric data types together. This operator has a different function when
it deals with strings. The ‘+’ sign simply joins together two or more string.
Example:
https://coder.computerscienceuk.com/coder/r094/
Length of Strings
The len() method helps us find the length of a string (i.e. how many characters it has –
including spaces)
https://coder.computerscienceuk.com/coder/vgZ0/