Skip to content

Commit

Permalink
fix: move break after looping over data sets
Browse files Browse the repository at this point in the history
- placed the beverage break too late, accidentally merged the wrong
ordering for swcarpentry#462
- make episode ordering match in reference.md
  • Loading branch information
alee committed Apr 28, 2020
1 parent 4e61467 commit 59e3ee7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 28 additions & 28 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,32 @@ for number in range(0,5):
~~~
{: .language-python}

## [Looping Over Data Sets]({{ page.root }}/13-looping-data-sets/)
## [Conditionals]({{ page.root }}/13-conditionals/)
- Defined similarly to a loop, using `if variable conditional value:`.
- For example, `if variable > 5:`.
- Use `elif:` for additional tests.
- Use `else:` for when if statement is not true.
- Can Combine more than one conditional by using `and` or `or`.
- Often used in combination with for loops.
- Conditions that can be used:
- `==` equal to.
- `>=` greater than or equal to.
- `<=` less than or equal to.
- `>` greater than.
- `<` less than.

~~~
for m in [3, 6, 7, 2, 8]:
if m > 5:
print(m, 'is large')
elif m == 5:
print(m, 'is 5')
else:
print(m, 'is small')
~~~
{: .language-python}

## [Looping Over Data Sets]({{ page.root }}/14-looping-data-sets/)
- Use a for loop: `for filename in [file1, file2]:`
- To find a set of files using a pattern use `glob.glob`
- Must import first using `import glob`.
Expand All @@ -141,7 +166,7 @@ for filename in glob.glob(*.txt):
~~~
{: .language-python}

## [Writing Functions]({{ page.root }}/14-writing-functions/)
## [Writing Functions]({{ page.root }}/16-writing-functions/)
- Define a function using `def function_name(parameters):`. Replace `parameters` with the variables to use when the function is executed.
- Run by using `function_name(parameters)`.
- To return a result to the caller use `return ...` in the function.
Expand All @@ -155,35 +180,10 @@ add_numbers(1, 4)
~~~
{: .language-python}

## [Variable Scope]({{ page.root }}/15-scope/)
## [Variable Scope]({{ page.root }}/17-scope/)
- A local variable is defined in a function and can only be seen and used within that function.
- A global variable is defined outside of a function and can be seen or used anywhere after definition.

## [Conditionals]({{ page.root }}/17-conditionals/)
- Defined similarly to a loop, using `if variable conditional value:`.
- For example, `if variable > 5:`.
- Use `elif:` for additional tests.
- Use `else:` for when if statement is not true.
- Can Combine more than one conditional by using `and` or `or`.
- Often used in combination with for loops.
- Conditions that can be used:
- `==` equal to.
- `>=` greater than or equal to.
- `<=` less than or equal to.
- `>` greater than.
- `<` less than.

~~~
for m in [3, 6, 7, 2, 8]:
if m > 5:
print(m, 'is large')
elif m == 5:
print(m, 'is 5')
else:
print(m, 'is small')
~~~
{: .language-python}

## [Programming Style]({{ page.root }}/18-style/)
- Document your code.
- Use clear and meaningful variable names.
Expand Down

0 comments on commit 59e3ee7

Please sign in to comment.