

! pip install jturtle
from jturtle import *
Настройки экрана screensize (400, 400) speed (8) bgcolor («lightblue»)
Функция для рисования одного лепестка def petal (radius, angle): color («red») fillcolor («pink») begin_fill () for _ in range (2): circle (radius, angle) left (180 — angle) end_fill ()
Рисуем цветок из лепестков penup () goto (0, -50) pendown () setheading (60) for _ in range (6): petal (60, 60) left (60)
Сердцевина цветка penup () goto (0, -20) pendown () color («yellow») begin_fill () circle (20) end_fill ()
Рисуем стебель penup () goto (0, -40) setheading (-90) color («green») pensize (5) pendown () forward (80)
hideturtle () done ()
particles = [] NUM_PARTICLES = 300
def setup (): size (800, 600) colorMode (HSB, 360, 100, 100, 100)
for _ in range (NUM_PARTICLES):
particles.append (Particle ())
def draw (): noStroke () fill (0, 15) rect (0, 0, width, height)
for p in particles:
p.apply_forces ()
p.update ()
p.check_edges ()
p.display ()
class Particle: def init(self): self.pos = PVector (random (width), random (height)) self.vel = PVector (0, 0) self.acc = PVector (0, 0)
self.max_speed = 3
self.noise_offset = PVector (random (1000), random (1000))
self.hue = map (self.pos.x, 0, width, 0, 360)
def apply_forces (self): noise_angle = noise (self.pos.x * 0.005, self.pos.y * 0.005, frameCount * 0.005) * TWO_PI * 2 noise_force = PVector.fromAngle (noise_angle) noise_force.setMag (0.05) self.acc.add (noise_force)
if mousePressed:
mouse_pos = PVector (mouseX, mouseY)
attraction_force = PVector.sub (mouse_pos, self.pos)
distance = max (attraction_force.mag (), 5)
attraction_force.normalize ()
strength = map (distance, 0, width/2, 0.1, 2.5)
attraction_force.mult (strength)
self.acc.add (attraction_force)
def update (self):
self.vel.add (self.acc)
self.vel.limit (self.max_speed)
self.pos.add (self.vel)
self.acc.mult (0)
def display (self):
current_hue = (self.hue \+ frameCount / 2.0) % 360
speed = self.vel.mag ()
particle_size = map (speed, 0, self.max_speed, 1, 6)
particle_saturation = map (speed, 0, self.max_speed, 100, 50)
stroke (current_hue, particle_saturation, 100, 80)
strokeWeight (particle_size)
point (self.pos.x, self.pos.y)
def check_edges (self):
if self.pos.x > width: self.pos.x = 0
if self.pos.x < 0: self.pos.x = width
if self.pos.y > height: self.pos.y = 0
if self.pos.y < 0: self.pos.y = height
try: df = pd.read_csv ('global_temperatures.csv') print («Data loaded successfully.») except FileNotFoundError: print («Error: 'global_temperatures.csv' not found. Using dummy data for demonstration.») # Create dummy data if the file is not found num_months = (2015 — 1750 + 1) * 12 data = { 'dt': pd.to_datetime (pd.date_range (start='01.01.1750', end='01.12.2015', freq='MS')), 'LandAverageTemperature': np.random.rand (num_months) * 20 — 5 + np.linspace (0, 5, num_months), 'LandMaxTemperature': np.random.rand (num_months) * 20 — 5 + np.linspace (0, 5, num_months) + 5, 'LandMinTemperature': np.random.rand (num_months) * 20 — 5 + np.linspace (0, 5, num_months) — 5, 'LandAndOceanAverageTemperature': np.random.rand (num_months) * 20 — 5 + np.linspace (0, 5, num_months) + 1 } df = pd.DataFrame (data)
df['dt'] = pd.to_datetime (df['dt']) df['Year'] = df['dt'].dt.year df['Month'] = df['dt'].dt.month df.dropna (subset=['LandAverageTemperature', 'LandAndOceanAverageTemperature'], inplace=True) df = df[df['Year'] >= 1850] # Filter for a more relevant period
df_yearly_avg = df.groupby ('Year')['LandAndOceanAverageTemperature'].mean ().reset_index () df_yearly_avg['RollingAvg_10Y'] = df_yearly_avg['LandAndOceanAverageTemperature'].rolling (window=10).mean ()
base_period_start = 1951 base_period_end = 1980 base_temp = df_yearly_avg[ (df_yearly_avg['Year'] >= base_period_start) & (df_yearly_avg['Year'] <= base_period_end) ]['LandAndOceanAverageTemperature'].mean () df_yearly_avg['Anomaly'] = df_yearly_avg['LandAndOceanAverageTemperature'] — base_temp
plt.style.use ('dark_background') sns.set_style ('darkgrid', {'axes.facecolor': '
plt.rcParams['font.family'] = 'sans-serif' plt.rcParams['font.sans-serif'] = ['Arial', 'Helvetica'] plt.rcParams['text.color'] = '#ABB2BF' plt.rcParams['axes.labelcolor'] = '#ABB2BF' plt.rcParams['xtick.color'] = '#ABB2BF' plt.rcParams['ytick.color'] = '#ABB2BF' plt.rcParams['axes.edgecolor'] = '#61AFEF'
accent_color_pos = '#E06C75' accent_color_neg = '#56B6C2'