-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_String.py
More file actions
43 lines (33 loc) · 1.06 KB
/
03_String.py
File metadata and controls
43 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# strings
simple_string = ('Get ready for the next battle')
my_string = ('Good jobs team')
print(len(simple_string))
print(len(my_string))
# Other string
print('hello\neveryone') #using \n
print('\thello everyone') # using \t
# format
name, surname, age = 'sergio', 'lattke', 23
print('my name is {} {} and im {} years old' .format(name, surname, age))
print('my name is %s %s and im %d years old' %(name, surname, age))
print(f'my name is {name} {surname} and im {age} years old')
#Sequences of Characters
language = 'python'
a, b, c, d, e, f = language
print(a)
print(b)
print(c)
print(d)
print(e)
print(f)
# division
language_slice = language[ : : -1]
print(language_slice)
# function
print(language.capitalize()) # uppercase the first letter
print(language.upper()) # uppercase all
print(language.count('t')) # count how many t have Python
print(language.isnumeric()) # Python is numeric? false
print(language.lower()) # lowercase all
print(language.upper().isupper()) #uppercase all and PYTHON is upper? true
print(language.startswith('py')) # python starts with py?