from random import randint
import pygame
POINTS = [(randint(20, 400), randint(20, 300)) for _ in range(int(input()))]
WHITE = (255, 255, 255)
def draw(scr, points):
for i in range(len(points) - 1):
pygame.draw.line(scr, WHITE, points[i], points[i + 1], 1)
pygame.init()
size = 400, 300
pygame.display.set_caption('title')
screen = pygame.display.set_mode(size)
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
screen.fill((0, 0, 0))
draw(screen, POINTS)
pygame.display.flip()
pygame.quit()
Можно так, но библиотеку pygame надо устанавливать из командой строки, или среды разработки которую вы используете
from random import randint
import pygame
POINTS = [(randint(20, 400), randint(20, 300)) for _ in range(int(input()))]
WHITE = (255, 255, 255)
def draw(scr, points):
for i in range(len(points) - 1):
pygame.draw.line(scr, WHITE, points[i], points[i + 1], 1)
pygame.init()
size = 400, 300
pygame.display.set_caption('title')
screen = pygame.display.set_mode(size)
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
screen.fill((0, 0, 0))
draw(screen, POINTS)
pygame.display.flip()
pygame.quit()
Можно так, но библиотеку pygame надо устанавливать из командой строки, или среды разработки которую вы используете