В
Все
У
Українська література
Г
Геометрия
Д
Другие предметы
Э
Экономика
Г
География
О
ОБЖ
М
Математика
М
МХК
Х
Химия
Қ
Қазақ тiлi
Л
Литература
У
Українська мова
О
Обществознание
Ф
Физика
А
Английский язык
А
Алгебра
И
История
Б
Беларуская мова
Б
Биология
М
Музыка
П
Право
И
Информатика
П
Психология
В
Видео-ответы
Н
Немецкий язык
Ф
Французский язык
О
Окружающий мир
Р
Русский язык
UlnaeMai
UlnaeMai
10.11.2021 08:50 •  Информатика

Напишите краткое эссе на английском, на тему:
“Problem solving: While loop”

Ответ:
0Neder0
0Neder0
13.10.2020 22:19

A while loop is a type of loop that runs as long as a logical condition is True. When the logical condition becomes False, the loop stops running. The general form of a while loop in Python is below:

while <logical_condition>: <code>

The keyword while must be included, as well as a <logical_condition> which can be evaluated as True or False. The <code> after the while statement must be indented. Each line of code runs in the while loop needs to be indented the same number of spaces. (Many code editors, including Jupyter notebooks, auto-indent after a whilestatement) If you add indentation manually, four space spaces is the Python standard.

An example of a while loop is below:

In [1]:

i = 0 while i<4: print(i) i = i+1

The first line i=0 creates the variable i and assigns it the value 0. The next line declares the logical condition needed to keep the loop running. The statement i<4 is True or False depending on the variable i. Since i=0, the statement i<4 is Trueand the while loop starts to run. The code inside while the loop prints the value of i then increases iby 1. When i=4, the statement i<4 is False and the while loop ends.

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