-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrings.py
56 lines (37 loc) · 844 Bytes
/
strings.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
print(type('its string'))
username = 'username'
password = 'password'
logString = '''
WOW
0 0
---
'''
print(logString)
fullName = 'test' + ' ' + 'one'
print(fullName)
# string concat
print('string'+'concat')
# print('string'+5) # error
print(type(int(str(100))))
print('string'+str(5))
# Escape sequence
weather = "\tIt's \"kind of\" sunny \n good day!!!"
print(weather)
# formatted strings
name = 'Punit'
age = 55
print(f'hi {name}. you are {age} years old')
print('hi {}. you are {} years old'.format('punit', '55'))
print('hi {}. you are {} years old'.format(name, age))
x = '0123456789'
# 0123456789
# [start:stop:stepover]
print(x[2])
print(x[0:2]) # 01
print(x[0:10:2]) # 02468
print(x[1::2]) # 13579
print(x[:5]) # 01234
print(x[:5:2]) # 024
print(x[-1]) # 9
print(x[::-1]) # 9876543210
print(x[::-2]) # 97531