diff --git a/TEMA8/MM0.py b/TEMA8/MM0.py new file mode 100644 index 0000000..e7d8bcb --- /dev/null +++ b/TEMA8/MM0.py @@ -0,0 +1,2 @@ +import MM2 +print('y=',MM2.vyhod) diff --git a/TEMA8/MM1.py b/TEMA8/MM1.py new file mode 100644 index 0000000..e9b68e9 --- /dev/null +++ b/TEMA8/MM1.py @@ -0,0 +1,22 @@ +def realdvig(xtt,kk1,TT,yti1,ytin1): + #Модель реального двигателя + yp=kk1*xtt #усилитель + yti1=yp+yti1 #Интегратор + ytin1=(yti1+TT*ytin1)/(TT+1) + return [yti1,ytin1] + +def tahogen(xtt,kk2,yti2): + #Модель тахогенератора + yp=kk2*xtt #усилитель + yti2=yp+yti2 #интегратор + return yti2 + +def nechus(xtt,gran): + #зона нечувствит + if xtt(-gran): + ytt=0 + elif xtt>=gran: + ytt=xtt-gran + elif xtt<=(-gran): + ytt=xtt+gran + return ytt diff --git a/TEMA8/MM2.py b/TEMA8/MM2.py new file mode 100644 index 0000000..7bcaf0a --- /dev/null +++ b/TEMA8/MM2.py @@ -0,0 +1,23 @@ +znach=input('k1,T,k2,Xm,A,F,N=').split(',') +k1=float(znach[0]) +T=float(znach[1]) +k2=float(znach[2]) +Xm=float(znach[3]) +A=float(znach[4]) +F=float(znach[5]) +N=int(znach[6]) + +import math +vhod=[] +for i in range(N): + vhod.append(A*math.sin((2*i*math.pi)/F)) + +import MM1 as mod +yi1=0;yin1=0;yi2=0 +vyhod=[] +for xt in vhod: + xt1=xt-yi2 #отрицательная обратная связь + [yi1,yin1]=mod.realdvig(xt1,k1,T,yi1,yin1) + yi2=mod.tahogen(yin1,k2,yi2) + yt=mod.nechus(yin1,Xm) + vyhod.append(yt) diff --git a/TEMA8/module1.py b/TEMA8/module1.py new file mode 100644 index 0000000..f52f78f --- /dev/null +++ b/TEMA8/module1.py @@ -0,0 +1,8 @@ +def read_func(name): + ans = [] + fp = open(name,'r') + for line in fp: + for num in line.strip().split(): + ans.append(float(num)) + fp.close() + return ans diff --git a/TEMA8/module2.py b/TEMA8/module2.py new file mode 100644 index 0000000..41a56e5 --- /dev/null +++ b/TEMA8/module2.py @@ -0,0 +1,15 @@ +import math as m +def count_corr(lst1,lst2): + n = min(len(lst1),len(lst2)) + sred1 = sum(lst1[:n+1])/(n) + sred2 = sum(lst2[:n+1])/(n) + down1 = 0;down2 = 0;up = 0 + for i in range(n): + down1 += ((lst1[i] - sred1)**2) + down2 += ((lst2[i] - sred2)**2) + up += (lst1[i] - sred1)*(lst2[i] - sred2) + print(up,m.sqrt(down1*down2)) + return up / m.sqrt(down1*down2) + + + diff --git a/TEMA8/module3.py b/TEMA8/module3.py new file mode 100644 index 0000000..e2f05fc --- /dev/null +++ b/TEMA8/module3.py @@ -0,0 +1,11 @@ +import module1 as m1,module2 as m2 +def brain(): + name1 = input("Введите имя первого текстового файла ") + name2 = input("Введите имя второго текстового файла ") + file1 = m1.read_func(name1) + file2 = m1.read_func(name2) + answer = m2.count_corr(file1,file2) + print(answer) + print("Коэффициент корреляции = {}".format(round(answer,3))) + + diff --git a/TEMA8/report.md b/TEMA8/report.md new file mode 100644 index 0000000..b312e34 --- /dev/null +++ b/TEMA8/report.md @@ -0,0 +1,597 @@ +# Отчет по теме 8 + +**Антонов Дмитрий, А-03-23** + +### 1.Начало работы, настройка текущего каталога +```py +import os;os.chdir('//Users//dmitrijantonov//Desktop//POAC//python-labs//TEMA8//') + +os.getcwd() +'/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8' +import sys,importlib +``` +### 2.Запуск модуля из командной строки +```py +import Mod1 +Mod1:Введите значение = 5 +Mod1:Значение perm1= 5 +``` +#### 2.1 Проверил класс модуля и получил список атрибутов +```py +dir() +['Mod1', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'importlib', 'os', 'sys'] +type(Mod1) + +dir(Mod1) +['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'perm1'] +``` +#### 2.2 Обращение к переменной внутри модуля +```py +Mod1.perm1 +'5' +import Mod1 +``` +- Ничего не произошло после импорт, так как модуль уже импортирован +```py +importlib.reload(Mod1) +Mod1:Введите значение = 3 +Mod1:Значение perm1= 3 + +Mod1.perm1 +'3' +``` +#### 2.2 Проверил какие модули уже импортированы +```py +print(sorted(sys.modules.keys())) +['Mod1', '__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +``` +- Удаление импортированного модуля +```py +sys.modules.pop('Mod1') + +print(sorted(sys.modules.keys())) +['__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +``` +- Повторный запуск модуля +```py +import Mod1 +Mod1:Введите значение = 5 +Mod1:Значение perm1= 5 +print(sorted(sys.modules.keys())) +['Mod1', '__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +sys.modules.pop('Mod1') + +``` +#### 2.3 Запуск на выполнение с помощью exec() +```py +exec(open('Mod1.py').read()) +Mod1:Введите значение = 9 +Mod1:Значение perm1= 9 +exec(open('Mod1.py').read()) +Mod1:Введите значение = 5 +Mod1:Значение perm1= 5 +dir() +['Mod1', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'importlib', 'os', 'perm1', 'sys'] +perm1 +'5' +exec(open('Mod1.py').read()) +Mod1:Введите значение = 8 +Mod1:Значение perm1= 8 +perm1 +'8' +from Mod1 import perm1 +Mod1:Введите значение = 78 +Mod1:Значение perm1= 78 +dir() +['Mod1', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'importlib', 'os', 'perm1', 'sys'] +print(sorted(sys.modules.keys())) +['Mod1', '__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +perm1 +'78' +from Mod2 import beta +dir() +['Mod1', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'beta', 'importlib', 'os', 'perm1', 'sys'] +g=beta(2) +****BETA**** +dir() +['Mod1', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'beta', 'g', 'importlib', 'os', 'perm1', 'sys'] +sys.modules.pop('Mod1') + +dir() +['Mod1', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'beta', 'g', 'importlib', 'os', 'perm1', 'sys'] +del(Mod1) +from Mod1 import perm1 +Mod1:Введите значение = 5 +Mod1:Значение perm1= 5 +dir() +['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'beta', 'g', 'importlib', 'os', 'perm1', 'sys'] +print(sorted(sys.modules.keys())) +['Mod1', 'Mod2', '__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +perm1 +'5' +from Mod2 import beta +g=beta(2) +****BETA**** +g +535.4916555247646 +dir() +['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'beta', 'g', 'importlib', 'os', 'perm1', 'sys'] +print(sorted(sys.modules.keys())) +['Mod1', 'Mod2', '__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +alpha() +Traceback (most recent call last): + File "", line 1, in + alpha() +NameError: name 'alpha' is not defined +from Mod2 import alpha as al +al() +****ALPHA**** +Значение t=9 +'9' +del al,beta +from Mod2 import alpha as al, beta as bt +del al,bt +dir() +['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'g', 'importlib', 'os', 'perm1', 'sys'] +from Mod2 import * +tt=alpha() +****ALPHA**** +Значение t=0.12 +uu=beta(float(tt)) +****BETA**** +print(uu) +1.4578913609506803 +sys.modules.pop('Mod1') + +sys.modules.pop('Mod2') + +print(sorted(sys.modules.keys())) +['__future__', '__main__', '_abc', '_ast', '_bisect', '_bz2', '_codecs', '_collections', '_collections_abc', '_colorize', '_compat_pickle', '_compression', '_datetime', '_frozen_importlib', '_frozen_importlib_external', '_functools', '_heapq', '_imp', '_io', '_lzma', '_opcode', '_opcode_metadata', '_operator', '_osx_support', '_pickle', '_pyrepl', '_pyrepl.pager', '_queue', '_random', '_signal', '_sitebuiltins', '_socket', '_sre', '_stat', '_string', '_struct', '_suggestions', '_sysconfigdata__darwin_darwin', '_thread', '_tkinter', '_tokenize', '_typing', '_warnings', '_weakref', '_weakrefset', 'abc', 'array', 'ast', 'bdb', 'binascii', 'bisect', 'builtins', 'bz2', 'codecs', 'collections', 'collections.abc', 'configparser', 'contextlib', 'copyreg', 'datetime', 'dis', 'encodings', 'encodings.aliases', 'encodings.utf_8', 'enum', 'errno', 'fnmatch', 'functools', 'genericpath', 'heapq', 'idlelib', 'idlelib.autocomplete', 'idlelib.autocomplete_w', 'idlelib.calltip', 'idlelib.calltip_w', 'idlelib.config', 'idlelib.debugger', 'idlelib.debugger_r', 'idlelib.debugobj', 'idlelib.debugobj_r', 'idlelib.hyperparser', 'idlelib.iomenu', 'idlelib.macosx', 'idlelib.multicall', 'idlelib.pyparse', 'idlelib.rpc', 'idlelib.run', 'idlelib.scrolledlist', 'idlelib.stackviewer', 'idlelib.tooltip', 'idlelib.tree', 'idlelib.util', 'idlelib.window', 'idlelib.zoomheight', 'importlib', 'importlib._abc', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib.machinery', 'importlib.util', 'inspect', 'io', 'ipaddress', 'itertools', 'keyword', 'linecache', 'lzma', 'marshal', 'math', 'opcode', 'operator', 'os', 'os.path', 'pickle', 'pkgutil', 'platform', 'plistlib', 'posix', 'posixpath', 'pydoc', 'pyexpat', 'pyexpat.errors', 'pyexpat.model', 'queue', 'random', 're', 're._casefix', 're._compiler', 're._constants', 're._parser', 'reprlib', 'select', 'selectors', 'shlex', 'shutil', 'site', 'socket', 'socketserver', 'stat', 'string', 'struct', 'sys', 'sysconfig', 'tempfile', 'textwrap', 'threading', 'time', 'tkinter', 'tkinter.constants', 'token', 'tokenize', 'traceback', 'types', 'typing', 'urllib', 'urllib.parse', 'warnings', 'weakref', 'xml', 'xml.parsers', 'xml.parsers.expat', 'xml.parsers.expat.errors', 'xml.parsers.expat.model', 'zipimport', 'zlib'] +import Mod0 +Mod1:Введите значение = 5 +Mod1:Значение perm1= 5 +perm1= 5 +****ALPHA**** +Значение t=10 +tt= 10 +****BETA**** +qq= 44031505860631.98 +dir() +['Mod0', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '__warningregistry__', 'alpha', 'beta', 'g', 'importlib', 'os', 'perm1', 'sys', 'tt', 'uu'] +Mod0.tt;Mod0.qq;Mod0.Mod1.perm1 +'10' +44031505860631.98 +'5' +R +Traceback (most recent call last): + File "", line 1, in + R +NameError: name 'R' is not defined + +===== RESTART: /Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/MM0.py ===== +k1,T,k2,Xm,A,F,N=2,3,4,1,6,4,3 +Traceback (most recent call last): + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/MM0.py", line 1, in + import MM2 + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/MM2.py", line 15, in + import MM1 as mod + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/MM1.py", line 6 + return [yti1,ytin1] + ^ +IndentationError: unindent does not match any outer indentation level + +===== RESTART: /Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/MM0.py ===== +k1,T,k2,Xm,A,F,N=2,3,4,1,6,4,3 +y= [0, 2.0, 0] + +===== RESTART: /Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/MM0.py ===== +k1,T,k2,Xm,A,F,N=5,5,5,2,3,4,8 +y= [0, 0.5, -3.833333333333333, 0, 19.990740740740744, -25.978395061728403, -22.99485596707819, 121.76114540466394] + +===== RESTART: /Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py ==== +main() +Traceback (most recent call last): + File "", line 1, in + main() +NameError: name 'main' is not defined. Did you mean: 'min'? +import os;os.chdir('//Users//dmitrijantonov//Desktop//POAC//python-labs//TEMA8//') +import os,sys,imp +Traceback (most recent call last): + File "", line 1, in + import os,sys,imp +ModuleNotFoundError: No module named 'imp' +import os,sys,impimport os,sys,importlib +SyntaxError: invalid syntax +import sys,importlib +import Mod2 +Mod2.beta + +Mod2.beta() +Traceback (most recent call last): + File "", line 1, in + Mod2.beta() +TypeError: beta() missing 1 required positional argument: 'q' +Mod2.beta(5) +****BETA**** +****ALPHA**** +Значение t=9 +обращание к альфа 9 +6635623.99934113 +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +'5' + +===== RESTART: /Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py ==== +import os;os.chdir('//Users//dmitrijantonov//Desktop//POAC//python-labs//TEMA8//') +import sys,importlib +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 13, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 6, in beta + expi=q*math.pi +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 13, in alpha + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 6, in beta +TypeError: can't multiply sequence by non-int of type 'float' + +===== RESTART: /Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py ==== +import os;os.chdir('//Users//dmitrijantonov//Desktop//POAC//python-labs//TEMA8//') +import sys,importlib +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + expi=q*math.pi +TypeError: can't multiply sequence by non-int of type 'float' +dir() +['Mod2', '__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'alpha', 'beta', 'importlib', 'os', 'sys'] +del(alpha,beta,Mod2) +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t= +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + expi=q*math.pi +TypeError: can't multiply sequence by non-int of type 'float' +del(alpha,beta,Mod2) +Traceback (most recent call last): + File "", line 1, in + del(alpha,beta,Mod2) +NameError: name 'alpha' is not defined +dir() +['Mod2', '__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'importlib', 'os', 'sys'] +import Mod2 +Mod2.beta() +Traceback (most recent call last): + File "", line 1, in + Mod2.beta() +TypeError: beta() missing 1 required positional argument: 'q' +Mod2.beta(2) +****BETA**** +535.4916555247646 +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=3 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + import math +TypeError: can't multiply sequence by non-int of type 'float' +dir(Mod2,alpha,beta) +Traceback (most recent call last): + File "", line 1, in + dir(Mod2,alpha,beta) +NameError: name 'alpha' is not defined +del(Mod2,alpha,beta) +Traceback (most recent call last): + File "", line 1, in + del(Mod2,alpha,beta) +NameError: name 'alpha' is not defined +dir() +['__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'importlib', 'os', 'sys'] +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + expi=float(q)*math.pi +TypeError: can't multiply sequence by non-int of type 'float' +import +SyntaxError: Expected one or more names after 'import' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print("q",q) +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print("q",type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=5 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(t)) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=8 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(float(t))) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=8.8 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(float(t))) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(int(t))) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +del(Mod2,alpha,beta) +Traceback (most recent call last): + File "", line 1, in + del(Mod2,alpha,beta) +NameError: name 'alpha' is not defined +dir() +['__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'importlib', 'os', 'sys'] +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта",beta(int(t))) + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + Mod2.alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта") + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + import math +TypeError: can't multiply sequence by non-int of type 'float' +tt=alpha() +Traceback (most recent call last): + File "", line 1, in + tt=alpha() +NameError: name 'alpha' is not defined +from Mod2 import * +tt=alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + tt=alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта") + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + import math +TypeError: can't multiply sequence by non-int of type 'float' +from Mod2 import * +tt=alpha() +****ALPHA**** +Значение t=0 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + tt=alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта") + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +del(Mod2,alpha,beta) +from Mod2 import * +tt=alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + tt=alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта") + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' +del(Mod2,alpha,beta) +Traceback (most recent call last): + File "", line 1, in + del(Mod2,alpha,beta) +NameError: name 'Mod2' is not defined +dir() +['__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'alpha', 'beta', 'importlib', 'os', 'sys'] +del(alpha,beta) +dir() +['__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'importlib', 'os', 'sys'] +from Mod2 import * +dir() +['__annotations__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'alpha', 'beta', 'importlib', 'os', 'sys'] +alpha.__doc__ +print(alpha.__doc__) +None +alpha() +****ALPHA**** +Значение t=9 +****BETA**** +Traceback (most recent call last): + File "", line 1, in + alpha() + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 4, in alpha + print("обращание к бетта") + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod2.py", line 10, in beta + print(type(q)) +TypeError: can't multiply sequence by non-int of type 'float' + +import Mod2 +Mod2.alpha() +****ALPHA**** +Значение t=9 +****BETA**** + +обращание к бетта 1902773895292.1592 +'9' + +import Mod2 +Mod2.beta(9) +****BETA**** + +****ALPHA**** +Значение t=9 +обращание к альфа 9 +1902773895292.1592 + +import Mod0 +Mod1:Введите значение = 9 +Mod1:Значение perm1= 9 +perm1= 9 +****ALPHA**** +Значение t=8 +tt= 8 +****BETA**** + +qq= 82226315585.59491 +Traceback (most recent call last): + File "", line 1, in + import Mod0 + File "/Users/dmitrijantonov/Desktop/POAC/python-labs/TEMA8/Mod0.py", line 10, in + print(t,expi) +NameE + +import Mod0 +Mod1:Введите значение = 5 +Mod1:Значение perm1= 5 +perm1= 5 +perm1= 15 +****ALPHA**** +Значение t=6 +tt= 6 +****BETA**** + +qq= 153552935.39544657 + +dir() +['Mod0', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'importlib', 'os', 'sys'] +perm1 +Traceback (most recent call last): + File "", line 1, in + perm1 +NameError: name 'perm1' is not defined +Mod0.perm1 * 2 +30 +tt * 2 +Traceback (most recent call last): + File "", line 1, in + tt * 2 +NameError: name 'tt' is not defined +qq*2 +Traceback (most recent call last): + File "", line 1, in + qq*2 +NameError: name 'qq' is not defined +Mod0.qq * 2 +307105870.79089314 +Mod0.tt * 2 +'66' +``` \ No newline at end of file diff --git a/TEMA8/task.md b/TEMA8/task.md new file mode 100644 index 0000000..6144aed --- /dev/null +++ b/TEMA8/task.md @@ -0,0 +1,12 @@ +# Общее контрольное задание по теме 8 + +**Антонов Дмитрий, А-03-23** +```py +import module3 +module3.brain() +Введите имя первого текстового файла testfile1.txt +Введите имя второго текстового файла testfile2.txt +-192.75 397.74528595572315 +-0.4846066233993201 +Коэффициент корреляции = -0.485 +``` \ No newline at end of file diff --git a/TEMA8/testfile1.txt b/TEMA8/testfile1.txt new file mode 100644 index 0000000..f87c95c --- /dev/null +++ b/TEMA8/testfile1.txt @@ -0,0 +1,2 @@ +1 2 3 +5 6 8 1212 \ No newline at end of file diff --git a/TEMA8/testfile2.txt b/TEMA8/testfile2.txt new file mode 100644 index 0000000..d0b0b0c --- /dev/null +++ b/TEMA8/testfile2.txt @@ -0,0 +1,2 @@ +112 3 4 +2 \ No newline at end of file