mirror of
https://github.com/davrot/pytutorial.git
synced 2025-04-16 12:16:42 +02:00
Create README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
parent
9d50e56e31
commit
ca8956cfdd
1 changed files with 37 additions and 0 deletions
37
python_basics/if/README.md
Normal file
37
python_basics/if/README.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Flow Control if, elif, else
|
||||
{:.no_toc}
|
||||
|
||||
<nav markdown="1" class="toc-class">
|
||||
* TOC
|
||||
{:toc}
|
||||
</nav>
|
||||
|
||||
## The goal
|
||||
|
||||
If I would have...
|
||||
|
||||
Questions to [David Rotermund](mailto:davrot@uni-bremen.de)
|
||||
|
||||
**Logic blocks need to be indented. Preferable with 4 spaces!**
|
||||
|
||||
## [The if statement](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement)
|
||||
|
||||
```python
|
||||
if i == 1:
|
||||
print("if")
|
||||
elif i == 2:
|
||||
print("elif brach A")
|
||||
elif i == 3:
|
||||
print("elif brach B")
|
||||
else:
|
||||
print("else -- default")
|
||||
```
|
||||
|
||||
## The full statement
|
||||
|
||||
```python
|
||||
if_stmt ::= "if" assignment_expression ":" suite
|
||||
("elif" assignment_expression ":" suite)*
|
||||
["else" ":" suite]
|
||||
```
|
||||
|
Loading…
Add table
Reference in a new issue