30
loading...
This website collects cookies to deliver better user experience
>>> print('any string')
any string
>>> print('string one', 'string two')
string one string two
>>> print([1, 2.0, 'three', ['f','o','u','r']])
[1, 2.0, 'three', ['f', 'o', 'u', 'r']]
>>> my_list = [41, 33, 48, 71, 60, 26]
>>> len(my_list)
6
>>> countries = ['Turks & Caicos', 'Grenada',
'Vanuatu', 'Lebanon', 'Barbados']
>>> for idx, item in enumerate(countries):
... print(f'{idx} - {item}')
...
0 - Turks & Caicos
1 - Grenada
2 - Vanuatu
3 - Lebanon
4 - Barbados
>>> sorted([64, 99, 69, 70, 53, 11, 42, 99, 5])
[5, 11, 42, 53, 64, 69, 70, 99, 99]
>>> with open('some_text.txt') as f:
... f.read()
...
'Whatever text was in the file'
>>> with open('writeable_file.csv', 'w') as f:
... f.write('one,two,three')
>>> type([])
<class 'list'>
>>> type('random text')
<class 'str'>
>>> isinstance('potato', str)
True
>>> isinstance('potato', list)
False
>>> help(len)
Help on built-in function len in module
builtins:
len(obj, /)
Return the number of items in a container.
(END)
>>> for number in range(4):
... print(number)
0
1
2
3
>>> for number in range(3, 33, 10):
... print(number)
3
13
23
Note :
(Image found on LinkedIn)