Tutorial - flow control Flashcards
1
Q
If statement syntax
A
if test: //code elif test: //code else: // code
2
Q
Case statement syntax
A
case value of value: code of value: code of value, value: code else: code
3
Q
what is discard statement
A
Is a do nothing statement.
The reason is that you have to cover every value that a case statement may contain. But it is not pratical.
The compiler knows that a case statement with an else part cannot fail and thus the error disappears.
4
Q
why string cases always need an else branch
A
because it is impossible to cover all possible string values
5
Q
While statement syntax
A
while test:
6
Q
For statement syntax (1 to 10 iteration)
A
for i in 1..10:
7
Q
For statement syntax (1 until less than 10 iteration)
A
for i in 0..<10:
8
Q
For statement syntax (string lenght)
A
for i in 0..