Functions, loops, if statements | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Functions, loops, if statements

what situations are functions, loops, if statements used? are there situations where they could be used interchangeably?

15th Feb 2017, 12:29 PM
Mich
Mich - avatar
1 ответ
0
Functions serve to reuse the code. You can just copy and paste contents of a function where it is called and you will be fine. If statemens are used in control flow of a program, use them if you need one block of code executed but not the other. Loops are there to reapeat a certain action till a given codition is false. Generally you want to combine them, depending on a task that you have to write more efficent code.
15th Feb 2017, 12:48 PM
Kyle Butler
Kyle Butler - avatar