Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren0
Functions, loops, if statements
what situations are functions, loops, if statements used? are there situations where they could be used interchangeably?
1 Antwort
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.