Python-Cheatsheet/less2.md

47 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[Ссылка на урок](https://youtu.be/XnWORRJVDfw?si=jsBtVj0EW-UPk3qM)
### List (Списки, похожи на массивы в 1С) ###
```python
price = [75, 80, 15, 41]
print(type(price), price)
print(price[0], price[1])
price.append(23)
print(price)
price.insert(0, 8)
print(price)
del price[0]print(price)
price.remove(15)
print(price)
print(80 in price)
print(max(price))
print(min(price))
price.append("строка")
print(price)
```
### Tuple, кортеж, не изменяемый список ###
```python
price = (75, 80, 15, 41)
del price[0]
```
### Dict (словарь, ассоциативный список, похож на соответствие в 1С) ###
```python
products = {}
products["стул"] = 100
products["стол"] = 200
print(products)
```
### Set, множества - "контейнер", содержащий не повторяющиеся элементы ###
```python
price_1 = set([75, 80, 15, 41])
price_2 = {80, 2, 10}
price_3 = price_1 | price_2
price_4 = price_1 & price_2
print(price_3)
print(price_4)
```
[Назад на главную](readme.md)