What are the names of the instances in the following code? Please put one instance per blank space and enter them in the order that the computer would read them. import turtle
wn = turtle.Screen()
jazz = turtle.Turtle()
jazz.forward(50)
jazz.right(90)
pop = turtle.Turtle()
pop.left(180)
pop.forward(76)
1)
s = 0
for k in range(-5,11):
s = s + 2 * k
print(s)
Прогоняются числа [-5;11)
s = 0 + 2 * -5 = -10
s = -10 + 2 * -4 = -18
s = -18 + 2 * -3 = -24
s = -24 + 2 * -2 = -28
s = -28 + 2 * -1 = -30
s = -30 + 2 * 0 = -30
s = -30 + 2 * 1 = -28
s = -28 + 2 * 2 = -24
s = -24 + 2 * 3 = -18
s = -18 + 2 * 4 = -10
s = -10 + 2 * 5 = 0
s = 0 + 2 * 6 = 12
s = 12 + 2 * 7 = 26
s = 26 + 2 * 8 = 42
s = 42 + 2 * 9 = 60
s = 60 + 2 * 10 = 80
ответ: 80
2)
s = 1
for k in range(1,30):
s = (k – 5) * s
print(s)
s = (1 - 5) * 1 = -4
s = (2 - 5) * -4 = 12
s = (3 - 5) * 12 = -24
s = (4 - 5) * -24 = 24
s = (5 - 5) * 24 = 0
s = (6 - 5) * 0 = 0
s = (7 - 5) * 0 = 0
s = (8 - 5) * 0 = 0
s = (9 - 5) * 0 = 0
s = (10 - 5) * 0 = 0
s = (11 - 5) * 0 = 0
s = (12 - 5) * 0 = 0
s = (13 - 5) * 0 = 0
s = (14 - 5) * 0 = 0
s = (15 - 5) * 0 = 0
s = (16 - 5) * 0 = 0
s = (17 - 5) * 0 = 0
s = (18 - 5) * 0 = 0
s = (19 - 5) * 0 = 0
s = (20 - 5) * 0 = 0
s = (21 - 5) * 0 = 0
s = (22 - 5) * 0 = 0
s = (23 - 5) * 0 = 0
s = (24 - 5) * 0 = 0
s = (25 - 5) * 0 = 0
s = (26 - 5) * 0 = 0
s = (27 - 5) * 0 = 0
s = (28 - 5) * 0 = 0
s = (29 - 5) * 0 = 0
ответ: 0
3)
x = 1
while x <= 10:
print(x)
x = x+2
Тут просто. Счетчик идет от одного, а цикл прерывается на 10. Тут никак не может быть четное число. А самое близкое нечетное к 10 - 9.
ответ: 9
4)
x = 1
while x <= 10:
print(x)
x = x + 1
else:
print("Готово")
Тут почти тоже самое. Только тут уже дойдет до 10 и напишет еще "готово"
ответ: 10 Готово.
Задача 1:
var x:longint;
i,c,sum:integer;
begin
c:=0;
sum:=0;
write('Введите число: '); readln(x);
while x <> 0 do begin
i:=x mod 10;
x:=x div 10;
if i mod 2 = 0 then begin
c:=c+1;
sum:=sum+i;
end;
end;
if c > 0 then write('Среднее арифметическое всех чётных чисел равно: ', sum/c:0:2)
else write('Чётных цифр нет!');
end.
Задача 2:
var x,y,sum:integer;
begin
sum:=0;
y:=0;
while True do begin
write('Введите число: '); readln(x);
if x = 0 then break
else if abs(x-y) > sum then sum:=abs(x-y);
y:=x;
end;
write(sum);
end.