# Software Carpentry Workshop (August 2020)
:::success
This document serves as a collective memory during the course.
Your instructor will guide you through, so don't worry about having to read it all right now :smile:
:::
## General Information
### Video Conference Room
:::spoiler
> Topic: HIFIS Software Carpentry
>
> Join Zoom Meeting
> https://eu01web.zoom.us/j/552801192?pwd=jqUVTd-TCY9LwBqvWvLi-4SnJA02Bw
>
> Meeting ID: 552 801 192
> Passcode: 210933
> One tap mobile
> +493056795800,,552801192#,,,,,,0#,,210933# Germany
> +496938079883,,552801192#,,,,,,0#,,210933# Germany
>
> Dial by your location
> +49 30 5679 5800 Germany
> +49 69 3807 9883 Germany
> +49 695 050 2596 Germany
> +49 69 7104 9922 Germany
> Meeting ID: 552 801 192
> Passcode: 210933
> Find your local number: https://eu01web.zoom.us/u/kbTp50pAhC
:::
### Chat
We will be using [LeapChat].
The Zoom internal chat is an emergency fallback in case something goes wrong.
### Event Pages
:::spoiler
> https://hifis-events.hzdr.de/event/20/
> https://hifis.gitlab.io/2020-08-19-hzdr/
:::
### Lesson Schedule
:::spoiler
| Lesson | When? | Instructor |
|---------------------------------|------------------|----------------|
| Automating Tasks with the Shell | Day 1, morning | Lokamani |
| Version Control with Git | Day 1, afternoon | Tobias Huste |
| Introduction to Python | Day 2, all day | Fredo Erxleben |
:::
---
# Day 1 (19.08.2020)
## Arrival
### Role Call
Please add your name in the list **below**:
* Lokamani (HZDR)
* Tobias Huste (HZDR)
* Fredo Erxleben (HZDR)
* Serhii Sorokin (HZDR)
* Michael Peichl (UFZ)
* Sharif Ibne Ibrahim (UFZ)
* Clara Benedicta Maria Müller (TENNO Systemhaus GmbH)
* Jonathan Frere (HZDR)
* Kabiru Nata'ala Muhammad (UFZ)
* Fola Ogungbemi (UFZ)
* Friederike Leßmöllmann (UFZ)
* Luise Fischer (UFZ)
* Özge Can (UFZ)
* Dirk Steglich (HZG)
* Hari Ganesan (HZG)
* Bahar Bahrami (UFZ)
* Emea Okorafor (UFZ)
### Warm-up Question
Please write down your main field of expertise and your most favorite cake (can also be a sweet):
* Fredo: Computer Science (Hardware, Software, Teaching), Zupfkuchen
* Tobias: Information System Technologies, Gefüllter Streußelkuchen
* Lokamani: Computational Materials Science, Sachertorte
* Fola: Ecotoxicology, Oatmeal cake
* Dirk: Computational Materials Science, "not-so-sweet cake"
* Michael: Economics and Climate Impact Assessment, NY Cheesecake
* Sharif: Groundwater Contamination & Management, Cheesecake
* Jonathan: Software Engineering (Observer!), Cheesecake
* Özge: Environmental research, brownies
* Friederike: Molecular Docking, Erdbeerkuchen
* Clara: Software Support (tSQL), Coffee
* Luise: russ. Zupfkuchen
* Bahar BAHRAMI
*
## Introduction to the Shell, aka How to Automate Things
Please turn to the setup: http://swcarpentry.github.io/shell-novice/setup.html
The zip file can be found at https://swcarpentry.github.io/shell-novice/data/data-shell.zip
Ready to go? (Downloaded zip file, unpacked zip file to the Desktop on your computer, opened a terminal) Put your initials here:
- TH
- MP
- FL
- CM
- JF
- SS
- ÖC
- HG
-
- LF
- KN
- SI
- DS
- BB
- FO
- MINGW64_NT-10.0-18363 ASAM018 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- $ uname -a MINGW64_NT-10.0-18363 ASAM018 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys bensalem@ASAM018 MINGW64 ~/Desktop $
-
### Paste the output of `uname -a`
- TH: Linux fwc008 5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020 x86_64 x86_64 x86_64 GNU/LinuxTH
- SS -> MINGW64_NT-10.0-18363 LAPTOP-57OV5E2U 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- LF: Linux frontend1 3.10.0-1127.18.2.el7.x86_64 #1 SMP Sun Jul 26 15:27:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- CM: Linux Archon 5.4.0-0.bpo.3-amd64 #1 SMP Debian 5.4.13-1~bpo10+1 (2020-02-07) x86_64 GNU/Linux
- FL: MINGW64_NT-10.0-18363 OEKOCHEM009 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- SI: MINGW64_NT-10.0-18363 met-mobile81 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- JF: Linux pop-os 5.4.0-7634-generic #38~1596560323~20.04~7719dbd-Ubuntu SMP Tue Aug 4 19:12:34 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
- MP: Linux peichl 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- rwin modmon068 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
- ÖC: MINGW64_NT-10.0-18363 leih-rz36 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- FO: MINGW64_NT-10.0-18363 BIOTOX70 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
* 1. - DS: MINGW64_NT-10.0-17134 RZNP1047 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- KN: MINGW64_NT-10.0-18363 UMB321 3.1.6-340.x86_64 2020-07-09 14:33 UTC x86_64 Msys
- HG: Darwin Haris-Air.fritz.box 18.7.0 Darwin Kernel Version 18.7.0: Mon Apr 27 20:09:39 PDT 2020; root:xnu-4903.278.35~1/RELEASE_X86_64 x86_64
#### Outtput of `ls -F /Desktop/data-shell`:
- TH: `creatures/ molecules/ notes.txt solar.pdf
data/ north-pacific-gyre/ pizza.cfg writing/`
- SI: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- BB: `creatures/ molecules/ notes.txt solar.pdf
data/ north-pacific-gyre/ pizza.cfg writing/`
- LF: `creatures/ molecules/ notes.txt solar.pdf
data/ north-pacific-gyre/ pizza.cfg writing/`
- DS: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- FL: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- MP: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- HG:
`creatures/ north-pacific-gyre/ solar.pdf
data/ notes.txt writing/
molecules/ pizza.cfg`
- SS: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- ÖC: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- CM: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- FO: `creatures/ data/ molecules/ north-pacific-gyre/ notes.txt pizza.cfg solar.pdf writing/`
- KN: `0.jpg Coursera/ data-shell/ 'GitHub Desktop.lnk'* molecules/ pizza.cfg 'Boost Note.lnk'* creatures/ desktop.ini GoToMeeting.lnk* north-pacific-gyre/ solar.pdf 'Cisco Webex Meetings.lnk'* data/ Evernote.lnk* 'Microsoft Edge.lnk'* notes.txt writing/`
### Exercise: Relative vs Absolute Path
Starting from /Users/amanda/data, which of the following commands could Amanda use to navigate to her home directory, which is /Users/amanda?
1. cd .
2. cd
3. cd /home/amanda
4. cd ../..
5. cd ~
6. cd home
7. cd ~/data/..
8. cd
9. cd ..
#### Copy and Paste in the Shell
**Copy from the Shell:** `Ctrl` + `Shift` + `C`
**Paste to the Shell:** `Ctrl` + `Shift` + `V`
:::danger
`Ctrl` + `C` in the shell means _cancel the current command_ which can be used to abort programs.
:::
#### Shell Symbols
* `.` means _the current directory_
* `..` means _one directory up_
* `~` means _the home directory_
* `*` _wildcard_, matches any amount of characters
* `?` _wildcard_, matches exectly one character
* `>` redirect the output of a command into a file
* `|` transfer data between commands
* So-called _pipe_
* :::info
Created with `AltGr` + `<` on German keyboards, `Alt` + `7` om Mac
:::
#### Shell Commands
Here is a list of _Shell_ commands we learned.
We will add them as we go along.
* `ls`: Show the contents of the current directory
* **l**i**s**t
* `pwd`: Shows you what the current directory is
* **P**rint **W**orking **D**irectory
* `clear`: Clear the text interface
* `man`: Show the manual page for a given command
* `cd`: **C**hange **d**irectory
* `mkdir`: **M**a**k**e **dir**ectory
* `mv`: **M**o**v**e a file
* Use `-r` for whole directories
* `nano`: open the _nano_ editor
* `cp`: **c**o**p**y a file
* Use `-r` for whole directories
* `rm`: **r**e**m**ove a file
* :warning: This is instant and permanent :skull_and_crossbones:
* Use `-r` for whole directories
* Use `-i` for getting asked before deletion
* `wc`: **w**ord **c**ount
* `cat`: con**cat**enate files
* `sort`: sort a given input
* `head`: output the first lines of a file
* `echo`: output the given input
* Useful for creating short files quickly
* Also useful in scripts
:::success
Here is a very comprehensive reference for all that we talked about in the workshop (and more) https://swcarpentry.github.io/shell-novice/reference/
:::
---
### Day 1 Morning: Feedback Session
#### Things, I liked:
* Exercises help not to fall asleep :D
* I would like to thank you because the begining seems very important to not to get lost and continue the course. very patient and relax atmosphere!
* The flow of the lessons
* The exercises as well
* get detailed overview of the basic commands
* nice, detailed explanations & good interactive exercises (surveys)
* well-organized, easy to follow, useful checkpoints using polls
*
#### Things, I did not like:
* The tutor is a little bit too fast at the begining. But we adapt to the speed
* some links do not work.
:::info
**Lunch Break** until 13:45
Afterwards: **Shell-Shenanigans** until 14:00
Afterwards: **Git**
:::
## Version Control with Git
## Please paste the output of `git --version` here:
TH: git version 2.28.0
BB: git version 2.27.0
ÖC: git version 2.28.0.windows.1
LF: git version 2.22.4
CM: git version 2.20.1
FL: git version 2.28.0.windows.1
SI : git version 2.28.0.windows.1
DS: git version 2.28.0.windows.1
SS: git version 2.28.0.windows.1
KN: git version 2.28.0.windows.1
HG: git version 2.20.1 (Apple Git-117)
MP: git version 2.17.1
## Choosing an Editor
| Editor | Git Configuration Command |
|--------|---------------------------|
| Atom | `$ git config --global core.editor "atom --wait"`
| nano | `$ git config --global core.editor "nano -w"`
| BBEdit (Mac, with command line tools) | `$ git config --global core.editor "bbedit -w"`
| Sublime Text (Mac) | `$ git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n -w"`
| Sublime Text (Win, 32-bit install) | `$ git config --global core.editor "'c:/program files (x86)/sublime text 3/sublime_text.exe' -w"`
| Sublime Text (Win, 64-bit install) | `$ git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w"`
| Notepad++ (Win, 32-bit install) | `$ git config --global core.editor "'c:/program files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"`
| Notepad++ (Win, 64-bit install) | `$ git config --global core.editor "'c:/program files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"`
| Kate (Linux) | `$ git config --global core.editor "kate"`
| Gedit (Linux) |`$ git config --global core.editor "gedit --wait --new-window"`
| Scratch (Linux) | `$ git config --global core.editor "scratch-text-editor"`
| Emacs | `$ git config --global core.editor "emacs"`
| Vim | `$ git config --global core.editor "vim"`
| VS Code | `$ git config --global core.editor "code --wait"`
:::success
Git configuration variables list: https://git-scm.com/docs/git-config#_variables
:::
### Git Commands
Here is a list of _Git_ commands we learned.
We will add them as we go along.
* `git config`: Change your configuration for the git program
* This is what in other programs is known as _settings_ or _preferences_
* `git init`: Initialize a new, empty git repository
* `git status`: current status of the project
* `git add`: add content to staging area
* `git commit -m`: add commit message and move content to local repository
* `git log`: access all git commits
* `git diff`: access changes in the repository
* `git diff --staged`: access changes in staging area
*
---
### Exercises
#### :pencil: Exercise `git-3.1` - _Places to Create Git Repositories_
Along with tracking information about planets (the project we have already
created), Dracula would also like to track information about moons. Despite
Wolfman’s concerns, Dracula creates a `moons` project inside his `planets`
project with the following sequence of commands:
```shell=
$ cd ~/Desktop # return to Desktop directory
$ cd planets # go into planets directory, which is already a Git repository
$ ls -a # ensure the .git subdirectory is still present in the planets directory
$ mkdir moons # make a subdirectory planets/moons
$ cd moons # go into moons subdirectory
$ git init # make the moons subdirectory a Git repository
$ ls -a # ensure the .git subdirectory is present indicating we have created a new Git repository
```
Is the `git init` command, run inside the `moons` subdirectory, required for
tracking files stored in the `moons` subdirectory?
**Discuss. Take notes below. :arrow_down:**
* Fredo spoiled, the answer is no :D
* no, because moon is a subset of planets
* `Sub-repositories`, actually :nerd_face:
* Nope, it's not foreseen
* No
* moons already exists as a repository
* moons is inside an existing repository, so no
### Please put your GitLab.com username below
- TH: tobiashuste
- DS: Steglich1910
- MP: @MIcha_
- SI: @sibrahim102
- LF: @fischerl
- CM: @An4nke
- HG: ganesan87
- KN: kbnataala
- FO: @folaeclipse
- BB: @BaharBAHRAMI
- ÖC: ozgedjan
- SS: @alljustforfun
- FL: @FLessi
:::success
### Good Commit Messages Guide
One of the many good guides how to write good commit messages:
https://chris.beams.io/posts/git-commit/
:::
:::success
### Additional useful material
- [Pro Git Book](https://git-scm.com/book/en/v2)
- [Distributed Version control](https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control#_distributed_version_control_systems)
- [Detached HEAD state](https://git-scm.com/docs/git-checkout#_detached_head)
- [Self-paced learning material](https://swcarpentry.github.io/git-novice/)
:::
### Day 1 Afternoon: Feedback Session
#### Things, I liked:
* You always answer the question very good and it's quiet funny sometimes.
* very helpful, it will be also good to use some slides to explain the background before we jump into commands (especially for Git!).
* you are all very patent and always helping us out
* I like the way you describe everything very clearly and not too fast :)
* The exercises and the explanations given afterwards
#### Things, I did not like:
* more examples for working with GitLab
* Maybe more extended motivation, where .git is advantageous to conventional approaches.
* more concrete examples of cases using Git
---
# Day 2 (20.08.2020)
## Arrival
### Role Call
Please add your name in the list **below**:
* Tobias Huste (HZDR)
* Fredo Erxleben (HZDR)
* Lokamani (HZDR)
* Dirk Steglich (HZG) - Fortran, Pascal, python (little)
* Friederike Leßmöllmann (UFZ) - Python (just very superficial)
* Kabiru Nata'ala Muhammad (UFZ)
* Özge Can (UFZ) - Basics of: C, python
* Sharif Ibne Ibrahim (UFZ) - Python but very little
* Serhii Sorokin (HZDR) - C/C++, Labview, Wolfram Mathematica
* Fola Ogungbemi (UFZ) - introductry python and R
* Hari Ganesan (HZG) - C/C++, Python, Fortran, Java
* Kabiru Nata'ala Muhammad - R
* Luise Fischer (UFZ): Python, MATLAB, C#, Julia
* Bahar BAHRAMi: R
* Clara - Perl, Rust, R, SQL (diverse)
* Michael Peichl (UFZ) - R, Python
* EMEA OKORAFOR (UFZ)
## Introduction to Python
### Quick Check: Is IPython Working?
Put in your initials below once you have started IPython:
### How to Exit IPython?
Use the command `exit()`. Confirm with the _Enter_ key.
Alternatively try the `Ctrl` + `D` key combination.
### Exercises
---
#### Exercise 1.0: Naming Variables
Which is a better variable name, `m`, `min`, or `minutes`? Why?
_Hint:_ think about which code you would rather inherit from someone who is leaving the lab:
1) `ts = m * 60 + s`
2) `tot_sec = min * 60 + sec`
3) `total_seconds = minutes * 60 + seconds`
##### Type your answers below :arrow_down:
* 3) always make your code as clear as possible or add a comment
* 3 - Clear to understand for everyone
* 3: self-explaining names. min means: minimum
* 3 clear documentation and clear variable names, doesn't make a difference in storage space
* 3 - It makes the code readable
* 3; clear documentation
* 3) no ambiguity
* 2) informative and short
* 2) gives enough information to understand, but still short
* 2) same as above
* 3) because min could be a function refering to minimum
---
#### Exercise 1.5: Slicing (Advanced)
Assume `thing` is a string and `low`, `high`, `number` are positive integer values, while `some-negative-number` is a negative integer value:
1) What does `thing[low:high]` do?
2) What does `thing[low:]` (without a value after the colon) do?
3) What does `thing[:high]` (without a value before the colon) do?
4) What does `thing[:]` (just a colon) do?
5) What does `thing[number:some-negative-number]` do?
6) What happens when you choose a high value which is out of range?
* (e.g., try `atom_name[0:15]`)
##### Post your answers :arrow_down::
*
* 1) chars from low to high-1;
* 2) from low to the end
* 3) from beginning to the high-1
* 4) all the elements
* 5) negative is the limit counting from the end
* from number to len(thing)-|some_negative_number|
* 6) all the characters.
- can I go with the answers above;) - agreed upon
- I agree
* 1) print all positive integers
* 2) only integer number for low
* 3) only integer number for ghigh
* 4) all values
* 5) characters from number to some-negative-number
* 6) generates all characters of the string
*
* 4) print full string (start - end)
* 1. characters from the value of low to high
2.characters from the value of low to the end
3.characters from the beginning to the value of high
4.all the characters
5.should be something with reversing (?) but my values produced no output
6.from beginning to the end, like [0:]
*
1. shows the range from low to high
2. spit out the sting with all charc.
3. spit out max num charc.
4. spit out the sting with all charc.
5. spit out first charc.
6. spit out the sting with all charc.
* 1.characters from low to high-1
___
| 0 | 1 | 2 |
|---|---|---|
| b | o | r |
---
#### Exercise 4.1 - Fill in the Blanks
Fill in the blanks so that the program below produces the output shown.
```python
*
print('first time:', values)
values = values[____]
print('second time:', values)
```
**Output**
```
first time: [1, 3, 5]
second time: [3, 5]
```
##### Post your solutions :arrow_down:
```python
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:3]
print('second time:', values)
```
```python
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:3]
print('second time:', values)
```
values = ____
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[-1, 2]
print('second time:', values)
* KN
```python
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:]
print('second time:', values)
```
values = ____
values.____(1)
values.____(3)
values.____(5)
print('first time:', values)
values = values[____]
print('second time:', values)
```
* CM
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:3]
print('second time:', values)
*HG~~
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:]
print('second time:', values)
```python
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[]
print('second time:', values)
```
```python
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:]
print('second time:', values)
```
```python
values = []
values.append(1)
values.append(3)
values.append(5)
print('first time:', values)
values = values[1:3]
print('second time:', values)
```
---
---
#### Exercise 6.2 - Trimming Values
Fill in the blanks so that this program creates a new list containing `0` where the original list’s values were negative and `1` where the original list’s values were positive.
```python
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0.:
result.append(0)
else:
result.append(1)
print(result)
```
**Desired Output:**
```
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = ____
for value in original:
if (value<0):
result.append(0)
else:
result.append(1)
print(result)
```
**Desired output:**
```
[0, 1, 1, 1, 0, 1]
```
##### Post your solutions :arrow_down:
```python
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value<0:
result.append(0)
else:
result.append(1)
print(result)
```
```python
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = ____
for value in original:
if ____:
result.append(0)
else:
____
print(result)
```
S
*
```python
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
```
*
```python
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
```
*
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
```
**Desired Output:**
```
[0, 1, 1, 1, 0, 1]
```
CM:
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
*BB:
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
[0, 1, 1, 1, 0, 1]
--
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
```python
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
```
```
SI:
original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]
result = []
for value in original:
if value < 0:
result.append(0)
else:
result.append(1)
print(result)
```
---
#### Exercise 7.3 - Beatbox
Write a function called `beatbox(…)` that takes a number and prints output as follows:
* If this number can be divided by _3_ without remainder, print the text `"Dum"`.
* If the number can be divided by _5_ without remainder, print the text `"Tsss"`
* If the number can be divided by _3_ and by _5_ without remainder print the text `"DumTsss"`
* Otherwise print nothing
You can test your function with the following code:
```python
for number in range(0, 20):
beatbox(number)
```
**Expected Output:**
```
DumTsss
Dum
Tsss
Dum
Dum
Tsss
Dum
DumTsss
Dum
```
CM
```python
def beatbox(nr):
if nr % 3 == 1:
print("Dum")
elif nr % 3 == 2:
print("Tss")
elif nr % 3 == 0:
print("DumTss")
for number in range(0, 20):
beatbox(number)
```
> **Hint:** You can check if a number can be divided by another number by using the `%`-operator (called _modulo_), which gives you the remainder of a division.
> If `a % b == 0` then `a` could be divided by `b` without remainder.
##### Post your solutions
```python
def beatbox(number):
if number % 3 == 0 and number % 5 == 0:
print("DumTss")
if number % 3 == 0:
print("Dum")
if number % 5 == 0:
print("Tsss")
```
```python
S:
def beatbox(number):
if number%3==0 and number%5==0:
print("DumTsss")
elif number%3==0:
print("Dum")
elif number%5==0:
print("Tsss")
for number in range(0, 20):
beatbox(number)
```
```python
def beatbox(number):
if number%3==0 and number%5==0:
print("DumTsss")
elif number%5==0:
print("Tsss")
elif number%3==0:
print("Dum")
```
* HG:
```python
def beatbox(number):
if(number%3):
if(number%5):
print("dumTsss")
else: print("dum")
elif(number%5): print("Tsss")
else: print("")
```
---
```python
for number in range(0, 20):
beatbox(number)
if (number % 3 == 0) and (number % 5 == 0)
print("DumTsss")
elif (number % 3 == 0):
print("Dum")
elif (number % 5 == 0):
print("Tsss")
else:
print("Nothing")
```
```python
beatbox(number):
if (number%3==0) and (number%5==0):
print("DumTss")
elif number%5==0:
print("Tss")
elif (number%3==0):
print("Dum")
for number in range(0, 20):
beatbox(number)
```
---
```python
def beatbox(number):
if number % 3 == 0 and number % 5 == 0:
print("DumTssss")
elif number % 3 == 0:
print("Dum")
elif number % 5 == 0:
print("Tsss")
```
```python
SI
def beatbox(number):
for number in range(0, 20):
if number % 3 == 0:
print ("Dum")
elif number % 5 == 0:
print ("Tsss")
elif number % 3 == 0 and number % 5 == 0:
print("DumTsss")
else:
print("nothing")
return number
```
```python
def beatbox(x):
if x % 3 == 0:
print ("Dum")
elif x % 5 == 0:
print ("Tsss")
elif x % 3 ==0 and x % 5==0:
print ("DumTsss")
else:
print ("")
```
```python
FL:
def beatbox(numbers):
if numbers % 3 == 0 and numbers % 5 == 0:
print ("DumTsss")
elif numbers % 3 == 0:
print("Dum")
elif numbers % 5 == 0:
print ("Tsss")
```
```python
FL:
def beatbox(numbers):
if numbers % 3 == 0:
print("Dum")
elif numbers % 5 == 0:
print ("Tsss")
else:
if numbers % 3 == 0 and numbers % 5 == 0:
print ("DumTsss")
```
---
---
:::success
### Tips and Tricks
- Use `%whos` in an iPython console to get a list of user-defined variables
- [iPython Built-in magic commands](https://ipython.readthedocs.io/en/stable/interactive/magics.html)
- [Summary of slice notation in Python](https://stackoverflow.com/a/509295)
- For reference, the [ASCII table](https://de.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange#ASCII-Tabelle).
- [Python Built-in Functions](https://docs.python.org/3/library/functions.html#built-in-functions)
- [PEP8 - Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)
- [The Python Standard Library](https://docs.python.org/3/library/)
- [Top 10 Data Science Libraries](https://hackr.io/blog/top-data-science-python-libraries)
- [Numpy documentation](https://numpy.org/doc/stable/)
- [Matplotlib - Visualization in Python](https://matplotlib.org/)
- [Sample Plots in Matplotlib](https://matplotlib.org/tutorials/introductory/sample_plots.html)
:::
### Day 2 Afternoon: Feedback Session
#### Things, I liked:
* Good explanations and examples
* Concepts and answers to the questions were explained via demonstration, great
* Fredo is always calm and ready to help
* :grin:
* I liked the examples and exercises
* Very step by stepintro, thanks.
* very useful tips and explanation
* very helpful solutions for the technical issues so far
* I like the explanation via demostration
* I like Git and python
* Shared documentation & chat is a really nice idea!
* well organized, cool tutors, and systematic approach.
* cool management of all the electronic systems: zoom, shared material, chats, ...
* very thorough and slow paced.
* All in all I liked the course very much!very helpful! thank you very much!
* Cool exercises
* nice docummentation and resources
* good and fast references/links side by side.
#### Things, I did not like:
* No initial motivation for Python. Some nice examples would be very encouranging in the beginning moving into slightly more boring stuff.
* maybe not in context of this workshop but I would have liked more details about numpy, pandas, matplotlib
* a bit to less time for the python libraries -> exercises would be nice
* less focus on library.
* less real/actual problems but i think it is okay considering the scope of the workshop.
* missing more focus on Python libaries
## Post-Workshop Survey
Please take 5 minutes to fill out the [Post Workshop Survey](https://carpentries.typeform.com/to/UgVdRQ?slug=2020-08-19-hzdr).
:::info
### Self-paced learning materiall
It's a mixture of these two courses:
- http://swcarpentry.github.io/python-novice-gapminder/
- https://swcarpentry.github.io/python-novice-inflammation
:::
[LeapChat]: https://www.leapchat.org/#WindmillPadlockUnyieldingGoldfishHybridArachnidOfficeUltrasoundExerciserCucumberAardvarkBarracudaAbrasionSledNestUnglovedHullabalooGearboxBathrobeRichesBoxlikeIrksomeCrumblePadlockRequest