| Int |
| Number = 5 |
| age = 22 |
| fnumber = 5.8 |
| name = 'Artem' |
| Greeting = 'Hello my World' |
| New_Greeting = 'hello' \ |
| print('%s %s' % (New_Greeting, Greeting[6:])) |
| # %s %s % (n1, n2) |
| a = 'Hello, my name is Artem' |
| len(a) |
| a.count('l') |
| a.capitalize() |
| a.upper() |
| a.lower() |
| a.find('l') |
| a.find('l', 5) |
| a.find('l', 5, 10) |
| a.find('my') |
| a.alnum() |
| print('123abc'.isalnum()) |
| True |
| print('123abc!'.isalnum()) |
| False |
| a.alpha() |
| print('123abc'.isalpha()) |
| print('abc'.isalpha()) |
| a.space() |
| print(' '.isspace()) |
| print(''.isspace()) |
| empty_string = ' |
| print(empty_string == '') |
| empty_string_probel = ' ' |
| print(empty_string_probel.strip(' ') == '') |
| print(empty_string.strip('') == '') |
| h = 'hello' |
| print(h.startswith("he")) # startswith() |
| print(h.endswith("lo")) # endswith() |
| # list |
| split = h.split('l') |
| print(type(split)) |
| print(split) |
| split = h.split('e') |
| print(split) |
| # <class 'list'> |
| # ['he', '', 'o'] |
| # ['h', 'llo'] |
| # функция split() |
| data = "12;3;6;25;74" |
| separated_data = data.split(';') |
| print(separated_data) |
| print('1', '2', '3', sep=' + ', end=' ') |
| print('=', 1 + 2 + 3) |
| # 1 + 2 + 3 = 6 |
| print('2+3=', 2 + 3, sep='') |
| # 2+3=5 |
| # ['12', '3', '6', '25', '74'] |
| python = 'python is fun' |
| print(python.partition('is ')) |
| print(python.partition('not ')) |
| python = "python is fun, isn't it" |
| print(python.partition('is')) |
| # ('python ', 'is ', 'fun') |
| # ('python is fun', '', '') |
| # ('python ', 'is ', " fun, isn't it") |
| # bool |
| status = True |
| # Math |
| # +, -, *, /, //, **, % |
| a = 5 |
| b = 10 |
| c = a + b |
| c = b - a |
| c = a * a |
| #c = b / a |
| #c = b // a |
| #c = a ** 2 |
| #c = b % 3 |
| c = 7 |
| #c = -c |
| #c = -c |
| d = 5.565 |
| #print( round( d ) ) |
| #import math |
| #print( math.floor( d ) ) |
| #floor |
| #print( math.ceil( d ) ) |
| #ceil |
| #пи |
| #import math |
| #print(math.pi) |
| import math |
| a = 5 |
| b = 10 |
| c = 7 |
| p = ( a + b + c ) / 2 |
| area = math.sqrt(p*(p-a)*(p-b)*(p-c)) |
| print( p, area ) |
| print((23 + 8) % 24) |
| speed = 108 |
| time = 12 |
| dist = time * speed |
| # # 1296 |
Комментарии