lukingrishal
15.05.2021 17:09

From turtle import * from random import *

t = Turtle()

t.penup()

t.goto(-100,100)

t.pendown()

t.speed(100)

#поле

for i in range(0,15):

t.write(i)

t.right(90)

t.forward(200)

#возврат

t.left(180)

t.forward(200)

t.right(90)

t.forward(20)

first=Turtle()

first.shape("turtle")

first.color("red")

first.penup()

first.goto(-120,70)

first.pendown()

second=Turtle()

second.shape("turtle")

second.color("blue")

second.penup()

second.goto(-120,40)

second.pendown()

third=Turtle()

third.shape("turtle")

third.color("yellow")

third.penup()

third.goto(-120,-20)

third.pendown()

four=Turtle()

four.shape("turtle")

four.color("green")

four.penup()

four.goto(-120,-50)

four.pendown()

five=Turtle()

five.shape("turtle")

five.color("purple")

five.penup()

five.goto(-120,-80)

five.pendown()

#зрители

bolCount = randint(1,10)

for i in range(0, bolCount):

bol = Turtle()

bol.shape("turtle")

bol.color(randint(0,255),randint(0,255),randint(0,255))

bol.penup()

bol.goto(-90+25*i, -120)

bol.pendown()

bol.left(90)

x_first=0

x_second=0

x_third = 0

x_four = 0

x_five = 0

text = input('Прогноз, какая черепаха победит?')

tex = Turtle()

tex.penup()

tex.goto(-120,120)

tex.hideturtle()

tex.write('Ты считаешь, что победит ' + text, font = ('Arial', 12, 'bold'))

while ((x_first<305) and (x_second<305) and (x_third<305) and (x_four<305) and x_five<305):

first_step = randint(1,5)

x_first += first_step

first.forward(first_step)

second_step = randint(1,5)

x_second += second_step

second.forward(second_step)

third_step = randint(1,5)

x_third += third_step

third.forward(third_step)

four_step = randint(1,5)

x_four += four_step

four.forward(four_step)

five_step = randint(1,5)

x_five += five_step

five.forward(five_step)

по этому коду надо выполнить задание:

С консоли мы можем угадать, какая черепашка победит, а с программы мы можем это однозначно определить!

Давай по завершению гонки выводить в консоль и на экран какая черешка победила.
язык python

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
двоечник60
12.06.2020 19:14
// PascalABC.NET 3.1, сборка 1218 от 12.04.2016
uses GraphABC;

procedure OutLightGreen(n:integer);
begin
  var OldColor:=FontColor;
  SetFontColor(clLightGreen);
  Write(n:5);
  SetFontColor(OldColor)
end;

begin
  var a:=MatrixRandom(10,14,-180,320);
  var m:=ReadInteger('n=');
  Writeln;
  SetFontColor(clWhite);
  Font.Style:=fsBold; Font.Name:='Courier';
  Brush.Color:=clBlack; Window.Clear(clBlack);
  var k:=0;
  for var i:=0 to 9 do begin
    for var j:=0 to 13 do
      if a[i,j]>m then begin
        Inc(k); OutLightGreen(a[i,j]) end
      else Write(a[i,j]:5);
    Writeln
    end;
  SetFontColor(clRed);
  Writeln('Количество элементов равно ',k)
end.

Дана матрица 10x14, заданная случайными числами на интервале [-180; 320]. подсчитать количество элем
Дана матрица 10x14, заданная случайными числами на интервале [-180; 320]. подсчитать количество элем
0,0(0 оценок)
Ответ:
Леночка177
05.04.2023 01:16
1.
const n=20; 
var
  a:array[1..n] of integer;
  i,k,s:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do begin
  a[i]:=Random(51)-25;
  Write(a[i]:4)
end;
writeln;
write('K = '); readln(k);
s:=0;
for i:=1 to n do 
 if a[i] mod k = 0 then s:=s+a[i];
Writeln('s = ',s);
end.

Пример:
Исходный массив:
18 -24 -4 -21 15 19 18 -16 -1 -8 7 -21 21 22 -24 -4 18 -16 24 4
K = 3
s = 24

2.
const n=10; 
var
  a:array[1..n] of integer;
  i:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do begin
  a[i]:=Random(11);
  Write(a[i]:4)
end;
writeln;
writeln('Выбранные элементы:');
for i:=1 to n do 
 if a[i]<=i then Write(a[i]:4) else write(' ':4);
Writeln;
end.

Пример:
Исходный массив:
   9   1   2   8   2   7   1  10   8   3
Выбранные элементы:
       1   2       2       1       8   3
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота