Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

115 строки
5.4 KiB
Python

Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32
Enter "help" below or click "Help" above for more information.
time_tuple = (2025, 9, 18, 16, 12, 46, 3, 261, 0)
time_obj = time.struct_time(time_tuple)
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
time_obj = time.struct_time(time_tuple)
NameError: name 'time' is not defined. Did you forget to import 'time'?
import time
time_obj = time.struct_time(time_tuple)
time_obj
time.struct_time(tm_year=2025, tm_mon=9, tm_mday=18, tm_hour=16, tm_min=12, tm_sec=46, tm_wday=3, tm_yday=261, tm_isdst=0)
seconds = time.mktime(time_obj)
seconds
1758201166.0
back_to_time = time.localtime(seconds
)
back_to_time
time.struct_time(tm_year=2025, tm_mon=9, tm_mday=18, tm_hour=16, tm_min=12, tm_sec=46, tm_wday=3, tm_yday=261, tm_isdst=0)
import pylab
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
import pylab
ModuleNotFoundError: No module named 'pylab'
import pylab
x=list(range(-3,55,4))
t=list(range(15))
pylab.plot(t,x) #Создание графика в оперативной памяти
[<matplotlib.lines.Line2D object at 0x0000027668162490>]
pylab.title('Первый график')
Text(0.5, 1.0, 'Первый график')
pylab.xlabel('время')
Text(0.5, 0, 'время')
pylab.ylabel('сигнал')
Text(0, 0.5, 'сигнал')
pylab.show() #Отображение графика на экране
X1=[12,6,8,10,7]
X2=[5,7,9,11,13]
pylab.plot(X1)
[<matplotlib.lines.Line2D object at 0x0000027669976C10>]
pylab.plot(X2)
[<matplotlib.lines.Line2D object at 0x0000027669976D50>]
pylab.show()
pylab.hist(grades, bins=5, edgecolor='black', alpha=0.7, color='skyblue')
Traceback (most recent call last):
File "<pyshell#24>", line 1, in <module>
pylab.hist(grades, bins=5, edgecolor='black', alpha=0.7, color='skyblue')
NameError: name 'grades' is not defined
grades = [85, 92, 78, 65, 90, 85, 88, 72, 95, 81, 85, 90, 78, 85, 92]
categories = ['A', 'B', 'C', 'D', 'F']
values = [3, 7, 8, 2, 1]
pylab.hist(grades, bins=5, edgecolor='black', alpha=0.7, color='skyblue')
(array([1., 1., 3., 5., 5.]), array([65., 71., 77., 83., 89., 95.]), <BarContainer object of 5 artists>)
pylab.title('Гистограмма распределения оценок')
Text(0.5, 1.0, 'Гистограмма распределения оценок')
pylab.xlabel('Оценки')
Text(0.5, 0, 'Оценки')
pylab.ylabel('Частота')
Text(0, 0.5, 'Частота')
pylab.grid(axis='y', alpha=0.75)
pylab.show()
pylab.show()
pylab.hist(grades, bins=5, edgecolor='black', alpha=0.7, color='skyblue')
(array([1., 1., 3., 5., 5.]), array([65., 71., 77., 83., 89., 95.]), <BarContainer object of 5 artists>)
pylab.title('Гистограмма распределения оценок')
Text(0.5, 1.0, 'Гистограмма распределения оценок')
pylab.xlabel('Оценки')
Text(0.5, 0, 'Оценки')
pylab.ylabel('Частота')
Text(0, 0.5, 'Частота')
pylab.grid(axis='y', alpha=0.75)
pylab.show()
data = [23, 45, 67, 34, 89, 56, 72, 41, 58, 64, 39, 51, 47, 62, 55]
pylab.bar(categories, values, color=['red', 'orange', 'yellow', 'green', 'blue'], alpha=0.7)
<BarContainer object of 5 artists>
pylab.title('Столбчатая диаграмма распределения по категориям')
Text(0.5, 1.0, 'Столбчатая диаграмма распределения по категориям')
pylab.xlabel('Категории')
Text(0.5, 0, 'Категории')
pylab.ylabel('Количество')
Text(0, 0.5, 'Количество')
pylab.grid(axis='y', alpha=0.75)
pylab.show()
mean_value = statistics.mean(data)
Traceback (most recent call last):
File "<pyshell#48>", line 1, in <module>
mean_value = statistics.mean(data)
NameError: name 'statistics' is not defined. Did you forget to import 'statistics'?
import statistics
>>> mean_value = statistics.mean(data)
>>> median_value = statistics.median(data)
>>> mode_value = statistics.mode(data)
>>> stdev_value = statistics.stdev(data)
>>> variance_value = statistics.variance(data)
>>> quantiles_value = statistics.quantiles(data, n=4)
>>> harmonic_mean_value = statistics.harmonic_mean(data)
>>> pylab.hist(data, bins=6, edgecolor='black', alpha=0.7, color='lightgreen', label='Распределение данных')
(array([1., 3., 4., 4., 2., 1.]), array([23., 34., 45., 56., 67., 78., 89.]), <BarContainer object of 6 artists>)
>>> pylab.axvline(mean_value, color='red', linestyle='--', linewidth=2, label=f'Среднее: {mean_value:.2f}')
<matplotlib.lines.Line2D object at 0x000002766864C2D0>
>>> pylab.axvline(median_value, color='blue', linestyle='--', linewidth=2, label=f'Медиана: {median_value}')
<matplotlib.lines.Line2D object at 0x000002766864C410>
>>> pylab.axvline(mode_value, color='green', linestyle='--', linewidth=2, label=f'Мода: {mode_value}')
<matplotlib.lines.Line2D object at 0x000002766864C550>
>>> pylab.title('Гистограмма данных со статистическими показателями')
Text(0.5, 1.0, 'Гистограмма данных со статистическими показателями')
>>> pylab.xlabel('Значения')
Text(0.5, 0, 'Значения')
>>> pylab.ylabel('Частота')
Text(0, 0.5, 'Частота')
>>> pylab.legend()
<matplotlib.legend.Legend object at 0x000002766813F620>
>>> pylab.grid(alpha=0.3)
>>> pylab.show()