форкнуто от main/python-labs
Сравнить коммиты
2 Коммитов
b2a3ae24b0
...
33daa4f793
| Автор | SHA1 | Дата |
|---|---|---|
|
|
33daa4f793 | 4 недель назад |
|
|
cac315d9a9 | 4 недель назад |
@ -0,0 +1,546 @@
|
||||
'Тема 3 Соловьёва Е. Д.'
|
||||
Python 3.13.6 (tags/v3.13.6:4e66535, Aug 6 2025, 14:36:00) [MSC v.1944 64 bit (AMD64)] on win32
|
||||
Enter "help" below or click "Help" above for more information.
|
||||
import os
|
||||
os.chdir('C:\\Users\\Ekaterina\\OneDrive\\Desktop\\Solovyova\\python-labs\\TEMA3')
|
||||
logiz1=bool(56)
|
||||
logiz2=bool(0)
|
||||
logiz3=bool("Beta")
|
||||
logiz4=bool("")
|
||||
logiz1
|
||||
True
|
||||
logiz2
|
||||
False
|
||||
logiz3
|
||||
True
|
||||
logiz4
|
||||
False
|
||||
tt1=int(198.6)
|
||||
tt1
|
||||
198
|
||||
tt2=int("-76")
|
||||
tt2'
|
||||
SyntaxError: unterminated string literal (detected at line 1)
|
||||
tt2
|
||||
-76
|
||||
tt2=int("-76")
|
||||
tt4=int("71",8)
|
||||
type(tt2)
|
||||
<class 'int'>
|
||||
tt3=int("B",16)
|
||||
tt3
|
||||
11
|
||||
tt4=int("71",8)
|
||||
tt4
|
||||
57
|
||||
tt5=int("98.76")
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#24>", line 1, in <module>
|
||||
tt5=int("98.76")
|
||||
ValueError: invalid literal for int() with base 10: '98.76'
|
||||
tt4 = int(71, 8)
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#25>", line 1, in <module>
|
||||
tt4 = int(71, 8)
|
||||
TypeError: int() can't convert non-string with explicit base
|
||||
a=int(2)
|
||||
a
|
||||
2
|
||||
flt1=float(789)
|
||||
flt1
|
||||
789.0
|
||||
flt2=float(-6.78e2)
|
||||
flt2
|
||||
-678.0
|
||||
flt3=float("Infinity")
|
||||
flt3
|
||||
inf
|
||||
flt4=float("-inf")
|
||||
flt4
|
||||
-inf
|
||||
hh=123
|
||||
dv1=bin(hh)
|
||||
dv1
|
||||
'0b1111011'
|
||||
vos1=oct(hh)
|
||||
vos1
|
||||
'0o173'
|
||||
shs1=hex(hh)
|
||||
shs1
|
||||
'0x7b'
|
||||
dv1=int(dv1,2)
|
||||
dv1
|
||||
123
|
||||
vos1=int(vos1,8)
|
||||
vos1=int(vos1,8)
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#46>", line 1, in <module>
|
||||
vos1=int(vos1,8)
|
||||
TypeError: int() can't convert non-string with explicit base
|
||||
vos1
|
||||
123
|
||||
shs1=int(shs1,16)
|
||||
shs1
|
||||
123
|
||||
strk1=str(23.6)
|
||||
strk1
|
||||
'23.6'
|
||||
strk2=str(logiz3)
|
||||
strk2
|
||||
'True'
|
||||
strk3=str(["A","B","C"])
|
||||
strk3
|
||||
"['A', 'B', 'C']"
|
||||
strk4=str(("A","B","C"))
|
||||
strk4
|
||||
"('A', 'B', 'C')"
|
||||
strk5=str({"A":1,"B":2,"C":9})
|
||||
strk5
|
||||
"{'A': 1, 'B': 2, 'C': 9}"
|
||||
print(strk1)
|
||||
23.6
|
||||
print(strk2)
|
||||
True
|
||||
print(strk3)
|
||||
['A', 'B', 'C']
|
||||
print(strk4)
|
||||
('A', 'B', 'C')
|
||||
print(strk5)
|
||||
{'A': 1, 'B': 2, 'C': 9}
|
||||
type(strk5)
|
||||
<class 'str'>
|
||||
spis1=list("Строка символов")
|
||||
spis1
|
||||
['С', 'т', 'р', 'о', 'к', 'а', ' ', 'с', 'и', 'м', 'в', 'о', 'л', 'о', 'в']
|
||||
spis2=list((124,236,-15,908))
|
||||
spis2
|
||||
[124, 236, -15, 908]
|
||||
spis3=list({"A":1,"B":2,"C":9})
|
||||
spis3
|
||||
['A', 'B', 'C']
|
||||
spis3 = list({"A":1,"B":2,"C":9}.values())
|
||||
spis3
|
||||
[1, 2, 9]
|
||||
spis3 = list({"A":1,"B":2,"C":9}.items())
|
||||
spis3
|
||||
[('A', 1), ('B', 2), ('C', 9)]
|
||||
spis3 = [value for value in {"A":1,"B":2,"C":9}.values() if value % 2 == 0]
|
||||
spis3
|
||||
[2]
|
||||
print(spis1)
|
||||
['С', 'т', 'р', 'о', 'к', 'а', ' ', 'с', 'и', 'м', 'в', 'о', 'л', 'о', 'в']
|
||||
kort7=tuple('Строка символов')
|
||||
|
||||
SyntaxError: unexpected indent
|
||||
kort7=tuple('Строка символов')
|
||||
kort7
|
||||
('С', 'т', 'р', 'о', 'к', 'а', ' ', 'с', 'и', 'м', 'в', 'о', 'л', 'о', 'в')
|
||||
kort8=tuple(spis2)
|
||||
kort8
|
||||
(124, 236, -15, 908)
|
||||
kort9=tuple({"A":1,"B":2,"C":9})
|
||||
kort9
|
||||
('A', 'B', 'C')
|
||||
del strk5, kort8
|
||||
fio='Solovyova E D'
|
||||
spis0=list(fio)
|
||||
spis0
|
||||
['S', 'o', 'l', 'o', 'v', 'y', 'o', 'v', 'a', ' ', 'E', ' ', 'D']
|
||||
kort0=tuple(fio)
|
||||
kort0
|
||||
('S', 'o', 'l', 'o', 'v', 'y', 'o', 'v', 'a', ' ', 'E', ' ', 'D')
|
||||
strk0=str(kort0)
|
||||
kort0=tuple(spis0)
|
||||
kort0
|
||||
('S', 'o', 'l', 'o', 'v', 'y', 'o', 'v', 'a', ' ', 'E', ' ', 'D')
|
||||
strk0=str(kort0)
|
||||
strk0
|
||||
"('S', 'o', 'l', 'o', 'v', 'y', 'o', 'v', 'a', ' ', 'E', ' ', 'D')"
|
||||
strk5
|
||||
|
||||
SyntaxError: unexpected indent
|
||||
strk5
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#98>", line 1, in <module>
|
||||
strk5
|
||||
NameError: name 'strk5' is not defined. Did you mean: 'strk1'?
|
||||
kort8
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#99>", line 1, in <module>
|
||||
kort8
|
||||
NameError: name 'kort8' is not defined. Did you mean: 'kort7'?
|
||||
12+7+90
|
||||
109
|
||||
5.689e-1 - 0.456
|
||||
0.11289999999999994
|
||||
23.6+54
|
||||
77.6
|
||||
14-56.7+89
|
||||
46.3
|
||||
-6.7*12
|
||||
-80.4
|
||||
-234.5/6
|
||||
-39.083333333333336
|
||||
a=178/45
|
||||
type(a)
|
||||
<class 'float'>
|
||||
a
|
||||
3.9555555555555557
|
||||
b=178//45,b
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#109>", line 1, in <module>
|
||||
b=178//45,b
|
||||
NameError: name 'b' is not defined
|
||||
b=178//45
|
||||
b
|
||||
3
|
||||
type(b)
|
||||
<class 'int'>
|
||||
c=-24.6//12.1
|
||||
c
|
||||
-3.0
|
||||
tipe(c)
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#115>", line 1, in <module>
|
||||
tipe(c)
|
||||
NameError: name 'tipe' is not defined. Did you mean: 'type'?
|
||||
type(c)
|
||||
<class 'float'>
|
||||
d = 56 // 6.01
|
||||
d
|
||||
9.0
|
||||
print(d)
|
||||
9.0
|
||||
type(d)
|
||||
<class 'float'>
|
||||
e = 7.54// 2
|
||||
у
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#122>", line 1, in <module>
|
||||
у
|
||||
NameError: name 'у' is not defined
|
||||
e
|
||||
3.0
|
||||
type(e)
|
||||
<class 'float'>
|
||||
f = -15 // 4
|
||||
а
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#126>", line 1, in <module>
|
||||
а
|
||||
NameError: name 'а' is not defined
|
||||
а
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#127>", line 1, in <module>
|
||||
а
|
||||
NameError: name 'а' is not defined
|
||||
f
|
||||
-4
|
||||
type(f)
|
||||
<class 'int'>
|
||||
148%33
|
||||
16
|
||||
12.6%3.8
|
||||
1.2000000000000002
|
||||
20 % 3.5
|
||||
2.5
|
||||
-17 % 5
|
||||
3
|
||||
15.7 % 4
|
||||
3.6999999999999993
|
||||
14**3
|
||||
2744
|
||||
e=2.7**3.6
|
||||
|
||||
SyntaxError: unexpected indent
|
||||
e=2.7**3.6
|
||||
14**3.6
|
||||
13367.830445904418
|
||||
2.7**3
|
||||
19.683000000000003
|
||||
z = complex(6, -8)
|
||||
z**2
|
||||
(-28-96j)
|
||||
2**z
|
||||
(47.34786346201795+43.06018840625417j)
|
||||
dv1=9
|
||||
dv1
|
||||
9
|
||||
dv2=~dv1
|
||||
dv2
|
||||
-10
|
||||
7&9
|
||||
1
|
||||
7&8
|
||||
0
|
||||
7|9
|
||||
15
|
||||
7|8
|
||||
15
|
||||
14|5
|
||||
15
|
||||
14^5
|
||||
11
|
||||
h=14
|
||||
g=h<<2
|
||||
g
|
||||
56
|
||||
g1=h>>1
|
||||
g1
|
||||
7
|
||||
g2=h>>2
|
||||
g2
|
||||
3
|
||||
bin(245)
|
||||
'0b11110101'
|
||||
k=245
|
||||
k<<2
|
||||
980
|
||||
m=k<<2
|
||||
m
|
||||
980
|
||||
k>>3
|
||||
30
|
||||
bin(456)
|
||||
'0b111001000'
|
||||
t=456
|
||||
t>>5
|
||||
14
|
||||
t<<14
|
||||
7471104
|
||||
'Система '+'регулирования'
|
||||
'Система регулирования'
|
||||
'ля-'*5
|
||||
'ля-ля-ля-ля-ля-'
|
||||
['ку','-']*3
|
||||
['ку', '-', 'ку', '-', 'ку', '-']
|
||||
('кис','-')*4
|
||||
('кис', '-', 'кис', '-', 'кис', '-', 'кис', '-')
|
||||
signal1=[0]*3+[1]*99
|
||||
signal1
|
||||
[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
||||
signal2=(0,)*3+(1,)*5+(0,)*7
|
||||
signal2
|
||||
(0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0)
|
||||
stroka='Система автоматического управления'
|
||||
'автомат' in stroka
|
||||
True
|
||||
'ку' in ['ку','-']*3
|
||||
True
|
||||
'ля-' in ('abc', 'de', 'fg', 'hi', 'jkl')
|
||||
False
|
||||
stroka='Температура = %g %s %g'
|
||||
print(stroka)
|
||||
Температура = %g %s %g
|
||||
stroka % (16,' меньше ',25)
|
||||
'Температура = 16 меньше 25'
|
||||
stroka='Система'
|
||||
stroka+=' регулирования'
|
||||
z
|
||||
(6-8j)
|
||||
z=10
|
||||
zz
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#189>", line 1, in <module>
|
||||
zz
|
||||
NameError: name 'zz' is not defined. Did you mean: 'z'?
|
||||
zz=10
|
||||
zz/=2
|
||||
zz
|
||||
5.0
|
||||
zz*=5
|
||||
zz
|
||||
25.0
|
||||
n1,n2,n3=(11,-3,'all')
|
||||
т3
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#196>", line 1, in <module>
|
||||
т3
|
||||
NameError: name 'т3' is not defined
|
||||
n3
|
||||
'all'
|
||||
161=/10
|
||||
SyntaxError: cannot assign to literal
|
||||
x=161
|
||||
x=/10
|
||||
SyntaxError: invalid syntax
|
||||
161//=10
|
||||
SyntaxError: 'literal' is an illegal expression for augmented assignment
|
||||
x//=10
|
||||
x
|
||||
16
|
||||
x=166
|
||||
x\\=10
|
||||
SyntaxError: unexpected character after line continuation character
|
||||
x//=10
|
||||
x
|
||||
16
|
||||
x%=2
|
||||
x
|
||||
0
|
||||
x=167
|
||||
x=2
|
||||
x**=4
|
||||
x
|
||||
16
|
||||
n1,n2,n3=[11,-3,'all']
|
||||
n1,n2,n3='11,-3,'all''
|
||||
SyntaxError: invalid syntax
|
||||
n1,n2,n3='11,-3,'a"
|
||||
SyntaxError: unterminated string literal (detected at line 1)
|
||||
n1,n2,n3='11,-3,'a' '
|
||||
SyntaxError: invalid syntax
|
||||
n1,n2,n3="11,-3,'all' "
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#218>", line 1, in <module>
|
||||
n1,n2,n3="11,-3,'all' "
|
||||
ValueError: too many values to unpack (expected 3)
|
||||
n1, n2, n3 = "11,-3,'a'"
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#219>", line 1, in <module>
|
||||
n1, n2, n3 = "11,-3,'a'"
|
||||
ValueError: too many values to unpack (expected 3)
|
||||
n1, n2, n3 = "11", "-3", "all"
|
||||
n1, n2, n3 = {11, -3, 'all'}
|
||||
print(n1, n2, n3)
|
||||
11 -3 all
|
||||
print(n1, n2, n3)
|
||||
11 -3 all
|
||||
n1, n2, n3 = {'a': 1, 'b': 2, 'c': 3}
|
||||
print(n1, n2, n3)
|
||||
a b c
|
||||
w
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#226>", line 1, in <module>
|
||||
w
|
||||
NameError: name 'w' is not defined
|
||||
v
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#227>", line 1, in <module>
|
||||
v
|
||||
NameError: name 'v' is not defined
|
||||
w=10
|
||||
v=20
|
||||
w==v
|
||||
False
|
||||
w!=v
|
||||
True
|
||||
w<v
|
||||
True
|
||||
w>v
|
||||
False
|
||||
w<=v
|
||||
True
|
||||
w=>v
|
||||
SyntaxError: invalid syntax
|
||||
w>=v
|
||||
False
|
||||
mnoz1={'pen','book','pen','iPhone','table','book'}
|
||||
'book' in mnoz1
|
||||
True
|
||||
'cap' in mnoz1
|
||||
False
|
||||
dic1={'Saratov':145, 'Orel':56, 'Vologda':45}
|
||||
'Vologda' in dic1
|
||||
True
|
||||
'Pskov' in dic1
|
||||
False
|
||||
56 in dic1.values()
|
||||
True
|
||||
dct1={'Institut':['AVTI','IEE','IBB'],'Depart':['UII','PM','VMSS','MM'],'gruppa': ['A-01-15','A-02-15']}
|
||||
'UII' in dct1['Depart']
|
||||
True
|
||||
dct1['Depart'][1] == 'MM'
|
||||
False
|
||||
a=17
|
||||
|
||||
SyntaxError: unexpected indent
|
||||
a=17
|
||||
b=-6
|
||||
(a>=b) and ('book' in mnoz1) and not ('Pskov' in dic1
|
||||
|
||||
)
|
||||
True
|
||||
x = 10
|
||||
y = 5
|
||||
name = "Anna"
|
||||
result1 = (x > y) and (len(name) == 4) and not (y < 0)
|
||||
print(result1)
|
||||
True
|
||||
(x > y) and (len(name) == 4) and not (y < 0)
|
||||
True
|
||||
price=3000
|
||||
color=blue
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#260>", line 1, in <module>
|
||||
color=blue
|
||||
NameError: name 'blue' is not defined
|
||||
color='blue'
|
||||
price1=4000
|
||||
(price<price1) and (color=='red')
|
||||
False
|
||||
w=v=10
|
||||
w is v
|
||||
True
|
||||
w1=['A','B']
|
||||
v1=['A','B']
|
||||
w1 is v1
|
||||
False
|
||||
|
||||
stroka='Микропроцессорная система управления'
|
||||
dir(stroka)
|
||||
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
|
||||
stroka.find('пр')
|
||||
5
|
||||
stroka.count("с")
|
||||
4
|
||||
stroka.replace(' у',' автоматического у')
|
||||
'Микропроцессорная система автоматического управления'
|
||||
spis22=stroka.split(' ')
|
||||
stroka.upper()
|
||||
'МИКРОПРОЦЕССОРНАЯ СИСТЕМА УПРАВЛЕНИЯ'
|
||||
stroka3=" ".join(spis22)
|
||||
stroka3.partition("с")
|
||||
('Микропроце', 'с', 'сорная система управления')
|
||||
stroka3.rpartition("с")
|
||||
('Микропроцессорная си', 'с', 'тема управления')
|
||||
strk1.format(1,89.7)
|
||||
'23.6'
|
||||
strk1='Момент времени 23.6 , значение = 23.6'
|
||||
strk2='Момент времени {1}, значение = {0}:{2}'
|
||||
strk2.format(36.7,2,'норма!')
|
||||
'Момент времени 2, значение = 36.7:норма!'
|
||||
strk1 = 'Момент времени {}, значение = {}'
|
||||
strk1.format(1, 89.7)
|
||||
'Момент времени 1, значение = 89.7'
|
||||
strk3='Момент времени {num}, значение = {znch}'
|
||||
strk3.format(znch=89.7,num=2)
|
||||
'Момент времени 2, значение = 89.7'
|
||||
spsk='a','b','c','d','e','f'
|
||||
spsk=[a,b,c,d,e,f]
|
||||
spsk.pop(2)
|
||||
-3.0
|
||||
spsk
|
||||
[17, -6, 9.0, 35.719843790663525, -4]
|
||||
spsk=['a,b,c,d,e,f']
|
||||
spsk
|
||||
['a,b,c,d,e,f']
|
||||
spsk.pop(2)
|
||||
Traceback (most recent call last):
|
||||
File "<pyshell#294>", line 1, in <module>
|
||||
spsk.pop(2)
|
||||
IndexError: pop index out of range
|
||||
spsk=['a','b','c','d','e','f']
|
||||
spsk.pop(2)
|
||||
'c'
|
||||
spsk
|
||||
['a', 'b', 'd', 'e', 'f']
|
||||
spsk.append('c')
|
||||
spsk
|
||||
['a', 'b', 'd', 'e', 'f', 'c']
|
||||
spsk.insert(2,'a')
|
||||
spsk
|
||||
['a', 'b', 'a', 'd', 'e', 'f', 'c']
|
||||
spsk.count('a')
|
||||
2
|
||||
|
||||
Загрузка…
Ссылка в новой задаче