GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PythonLearning/Mnozhestva.py at master · egormin/PythonLearning

Expand file tree

/

Mnozhestva.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
34 lines (27 loc) · 1.14 KB
/

Mnozhestva.py

Copy path

File metadata and controls

34 lines (27 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
##Mnozhestva - ih otlichie v tom, chto oni ne soderzhat povtoryzyuschihsya elementov
#elementy v nem ne uporyadochena i k elementu nelzya obratitsya po imeni. Tol'ko pereborom
# 1) Sozdanie mnozhestv
print("\nSozdanie mnozhestv")
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
print(basket) # {'banana', 'pear', 'orange', 'apple'}
a = set('abracadabra') # {'b', 'd', 'a', 'r', 'c'}
b = set('alacazam') # {'l', 'm', 'a', 'z', 'c'}
print(a)
print(b)
# 2) Rabota s mnozhestvami
print("\nRabota s mnozhestvami")
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
print('orange' in basket)
print('crabgrass' in basket)
# 2) Operacii s mnozhestvami
print("\nOperacii s mnozhestvami")
mnozh1 = {1, 2, 3}
mnozh2 = {2, 3, 4}
print(mnozh1-mnozh2) # 1 (to chto est v mnozh1 chego net v mnozh2)
print(mnozh2-mnozh1) # 4 (to chto est v mnozh1 chego net v mnozh2)
print(mnozh2 & mnozh1) # 2,3 (cifri, obschie v mnozh1 i mnozh2)
print(mnozh2 | mnozh1) # 1, 2, 3, 4 (obyedinenie mnozh1 i mnozh2)
print(mnozh2 ^ mnozh1) # 1, 4 (vse krome obschih)
# Preobrazovanie spiska v mnozhestvo
spisok = [1, 2, 5, 6]
mnozhestvo = set(spisok)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.