<jupyter_start><jupyter_text>Strings<jupyter_code>len('hello world.. it is a very beautiful day')
"New" + "found" + "land"<jupyter_output><empty_output><jupyter_text>str.joins() method<jupyter_code>colors = ';'.join(['#2ecc71','#e74c3c','#9b59b6'])
colors
colors.split(';')
' '.join(['Hello','World'])<jupyter_output><empty_output><jupyter_text>partition()<jupyter_code>'unforgettable'.partition('forget')
'waterbottle'.partition('water')<jupyter_output><empty_output><jupyter_text>partition used in conjunction with tuple unpacking<jupyter_code>departure,seperator,arrival = 'Singapore:NewYork'.partition(':')
departure
seperator
arrival<jupyter_output><empty_output><jupyter_text>if seperator is not required and used, then use _ as variable name<jupyter_code>origin, _, destination = ('Singapore-London').partition('-')
origin
destination<jupyter_output><empty_output><jupyter_text>String format<jupyter_code>'The age of {0} is {1}'.format('John',32)
'The age of {} is {}'.format('Richard',30)
'The current position is {latitude} {longtitude}'.format(latitude='60N', longtitude='5E')
'Galatic position x={pos[0]}, y={pos[1]}, z={pos[2]}'.format(pos=(52.5, 26, 100))
import math
'Math constant: pi = {m.pi}, e = {m.e}'.format(m=math)
'Math constant: pi = {m.pi:.3f}, e = {m.e:.3f}'.format(m=math)
value = 4 * 20
'The value is {value}'.format(value=value)<jupyter_output><empty_output><jupyter_text>f string<jupyter_code>value = 4*20
f'The value is {value}'
import datetime
f'The current time is {datetime.datetime.now().isoformat()}'
f'Math constant: pi = {math.pi}, e = {math.e}'
f'Math constant: pi = {math.pi:.3f}, e = {math.e:.3f}'
help(str)<jupyter_output>Help on class str in module builtins:

class str(object)
 |  str(object='') -> str
 |  str(bytes_or_buffer[, encoding[, errors]]) -> str
 |  
 |  Create a new string object from the given object. If encoding or
 |  errors is specified, then the object must expose a data buffer
 |  that will be decoded using the given encoding and error handler.
 |  Otherwise, returns the result of object.__str__() (if defined)
 |  or repr(object).
 |  encoding defaults to sys.getdefaultencoding().
 |  errors defaults to 'strict'.
 |  
 |  Methods defined here:
 |  
 |  __add__(self, value, /)
 |      Return self+value.
 |  
 |  __contains__(self, key, /)
 |      Return key in self.
 |  
 |  __eq__(self, value, /)
 |      Return self==value.
 |  
 |  __format__(self, format_spec, /)
 |      Return a formatted version of the string as described by format_spec.
 |  
 |  __ge__(self, value, /)
 |      Return self>=value.
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  [...]
{'fraction_non_alphanumeric': 0.1634182908545727, 'fraction_numerical': 0.014992503748125937, 'mean_word_length': 5.107551487414188, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '375563', 'license': 'MIT', 'n_tokens_mistral': 985, 'n_tokens_neox': 950, 'n_words': 219, 'path': '06.Core Python - Getting Started/07.Built-in Collections - Strings.ipynb', 'repo_name': 'ptyadana/python-dojo', 'size': '2668'}