Skip to content

Added Icons for Concept Exercises. #2431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
814293b
Added icons for concept exercises.
BethanyG May 15, 2021
2636365
Merge branch 'main' into exercise-icon-patrol
BethanyG May 29, 2021
9d9136f
Update CODEOWNERS
iHiD May 29, 2021
c150726
Renamed processing-logs to little-sisiters-vocab.
BethanyG May 19, 2021
939d470
Rewrote hints.md, instructions.md, and introduction.md.
BethanyG May 19, 2021
7a88da1
Rewrote config.json, design.md, and exemplar.py.
BethanyG May 19, 2021
dd02363
Rewrote stub file and strings_test.py
BethanyG May 19, 2021
28cbedf
Corrected malformed JSON.
BethanyG May 19, 2021
47ac0e4
Added rewritten exercise to config.json.
BethanyG May 19, 2021
b618bb2
Update exercises/concept/little-sisters-vocab/.docs/introduction.md
BethanyG May 20, 2021
06bc9b8
Update exercises/concept/little-sisters-vocab/.docs/introduction.md
BethanyG May 20, 2021
2ce8e62
Update exercises/concept/little-sisters-vocab/.docs/hints.md
BethanyG May 20, 2021
ecd0c6d
Added task annotations to test file and added newline to stub and exe…
BethanyG May 28, 2021
85fc685
Update exercises/concept/little-sisters-vocab/.docs/instructions.md
BethanyG May 29, 2021
551265f
Update config.json
BethanyG May 29, 2021
be3586e
Update exercises/concept/little-sisters-vocab/.docs/hints.md
BethanyG May 29, 2021
ccc5771
Apply suggestions from code review
BethanyG May 29, 2021
79586d9
Update exercises/concept/little-sisters-vocab/.docs/introduction.md
BethanyG May 29, 2021
c040acb
Update exercises/concept/little-sisters-vocab/.docs/introduction.md
BethanyG May 29, 2021
70ac4b1
Annotated test files with concept exercise tasks. Edited test files,…
BethanyG May 28, 2021
7cb2b57
Added newlines to stub files.
BethanyG May 28, 2021
e8e1d41
Further edited language in list methods about.md and introduction.md.
BethanyG May 21, 2021
3dd2348
Update concepts/list-methods/about.md
BethanyG May 26, 2021
c649f1e
Added code examples to introduction doc.
BethanyG May 20, 2021
c48f4d6
Edited strings about.md file.
BethanyG May 19, 2021
7d74a8c
Concept Conditionals Add Files (#2430)
BethanyG May 30, 2021
bb46a94
Rewrote/added instructions and introduction files.
BethanyG May 14, 2021
371b2d5
Added config design, and exemplar files.
BethanyG May 14, 2021
3573cef
Added stub file.
BethanyG May 14, 2021
aeb8fa4
Added hints file.
BethanyG May 14, 2021
5b7bfdd
Renamed exercise to mitigation meltdown.
BethanyG May 14, 2021
12f8d41
Renamed exercise folder to meltdown mitigation.
BethanyG May 14, 2021
b22648c
Added meltdown-mitigation exercise and ran prettier.
BethanyG May 14, 2021
1efd69c
Rewrote/added instructions and introduction files.
BethanyG May 14, 2021
6991896
Added hints file.
BethanyG May 14, 2021
604b688
Added code example to hint for combining comparisons and booleans.
BethanyG May 21, 2021
2f59c40
Corrected reactor typo.
BethanyG May 21, 2021
e3dd444
Annotated test file with task markers and added trailing lines to stu…
BethanyG May 28, 2021
f434a5e
removed results.json file and edited introduction to be in line with …
BethanyG May 29, 2021
6fa5fdf
Added icons for concept exercises.
BethanyG May 15, 2021
3948889
Merge branch 'exercise-icon-patrol' of https://github.com/BethanyG/py…
BethanyG May 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
* @exercism/python

# Maintainers
config/maintainers.json @exercism/maintainers-admin

Expand All @@ -8,4 +6,3 @@ config/maintainers.json @exercism/maintainers-admin

# Changes to `fetch-configlet` should be made in the `exercism/configlet` repo
bin/fetch-configlet @exercism/maintainers-admin

4 changes: 2 additions & 2 deletions concepts/conditionals/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"blurb": "TODO: add blurb for this concept",
"authors": ["bethanyg", "cmccandless"],
"blurb": "The conditionals 'if', 'elif' ('else + if'), and 'else' are used to control the flow of execution and make decisions in a program. Python doesn't have a formal case-switch statement ,and uses multiple 'elif's to serve a similar purpose. Conditionals pair with expressions and objects that must resolve to 'True' or 'False'.",
"authors": ["bethanyg", "sachsom95"],
"contributors": []
}
158 changes: 157 additions & 1 deletion concepts/conditionals/about.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,158 @@
#TODO: Add about for this concept.
# About

In Python, [`if`][if statement], `elif` (_a contraction of 'else and if'_) and `else` statements are used in Python to [control the flow][control flow tools] of execution and make decisions in a program.
Unlike many other programming languages, Python versions 3.9 and below do not offer a formal case-switch statement, instead using multiple `elif` statements to serve a similar purpose.

Python 3.10 introduces a variant case-switch statement called `pattern matching`, which will be covered separately in another concept.

Conditional statements use expressions that must resolve to `True` or `False` -- either by returning a `bool` directly, or by evaluating ["truthy" or "falsy"][truth value testing].



```python
x = 10
y = 5

# The comparison '>' returns the bool 'True',
# so the statement is printed.
if x > y:
print("x is greater than y")
...
>>> x is greater than y
```

When paired with `if`, an optional `else` code block will execute when the original `if` condition evaluates to `False`:

```python
x = 5
y = 10

# The comparison '>' here returns the bool False,
# so the 'else' block is executed instead of the 'if' block.
if x > y:
print("x is greater than y")
else:
print("y is greater than x")
...
>>> y is greater than x
```

`elif` allows for multiple evaluations/branches.

```python
x = 5
y = 10
z = 20

# The elif statement allows for the checking of more conditions.
if x > y:
print("x is greater than y and z")
elif y > z:
print("y is greater than x and z")
else:
print("z is great than x and y")
...
>>> z is great than x and y
```

[Boolen operations][boolean operations] and [comparisons][comparisons] can be combined with conditionals for more complex testing:

```python

>>> def classic_fizzbuzz(number):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz!'
elif number % 5 == 0:
return 'Buzz!'
elif number % 3 == 0:
return 'Fizz!'
else:
return str(number)

>>> classic_fizzbuzz(15)
'FizzBuzz!'

>>> classic_fizzbuzz(13)
'13'
```

Conditionals can also be nested.

```python
>>> def driving_status(driver_age, test_score):
if test_score >= 80:
if 18 > driver_age >= 16:
return "Student driver, needs supervision."
elif driver_age == 18:
return "Permitted driver, on probation."
elif driver_age > 18:
return "Fully licensed driver."
else:
return "Unlicensed!"


>>> driving_status(63, 78)
'Unlicsensed!'

>>> driving_status(16, 81)
'Student driver, needs supervision.'

>>> driving_status(23, 80)
'Fully licsensed driver.'
```

## Conditional expressions or "ternary operators"

While Python has no specific `?` ternary operator, it is possible to write single-line `conditional expressions`.
These take the form of `<value if True>` if `<conditional test>` else `<value if False>`.
Since these expressions can become hard to read, it's recommended to use this single-line form only if it shortens code and helps readability.


```python
def just_the_buzz(number):
return 'Buzz!' if number % 5 == 0 else str(number)

>>> just_the_buzz(15)
'Buzz!'

>>> just_the_buzz(10)
'10'
```

## Truthy and Falsy

In Python, any object can be tested for [truth value][truth value testing], and can therefore be used with a conditional, comparison, or boolean operation.
Objects that are evaluated in this fashion are considered "truthy" or "falsy", and used in a `boolean context`.

```python
>>> def truthy_test(thing):
if thing:
print('This is Truthy.')
else:
print("Nope. It's Falsey.")


# Empty container objects are considered Falsey.
>>> truthy_test([])
Nope. It's Falsey.

>>> truthy_test(['bear', 'pig', 'giraffe'])
This is Truthy.

# Empty strings are considered Falsey.
>>> truthy_test('')
Nope. It's Falsey.

>>> truthy_test('yes')
This is Truthy.

# 0 is also considered Falsey.
>>> truthy_test(0)
Nope. It's Falsey.
```

[if statement]: https://docs.python.org/3/reference/compound_stmts.html#the-if-statement
[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools
[truth value testing]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing
[boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
[comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons
82 changes: 81 additions & 1 deletion concepts/conditionals/introduction.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,82 @@
#TODO: Add introduction for this concept.
# Introduction

In Python, [`if`][if statement], `elif` (_a contraction of 'else and if'_) and `else` statements are used in Python to [control the flow][control flow tools] of execution and make decisions in a program.
Unlike many other programming languages, Python versions 3.9 and below do not offer a formal case-switch statement, instead using multiple `elif` statements to serve a similar purpose.

Python 3.10 introduces a variant case-switch statement called `pattern matching`, which will be covered separately in another concept.

Conditional statements use expressions that must resolve to `True` or `False` -- either by returning a `bool` directly, or by evaluating ["truthy" or "falsy"][truth value testing].


```python
x = 10
y = 5

# The comparison '>' returns the bool 'True',
# so the statement is printed.
if x > y:
print("x is greater than y")
...
>>> x is greater than y
```

When paired with `if`, an optional `else` code block will execute when the original `if` condition evaluates to `False`:

```python
x = 5
y = 10

# The comparison '>' here returns the bool False,
# so the 'else' block is executed instead of the 'if' block.
if x > y:
print("x is greater than y")
else:
print("y is greater than x")
...
>>> y is greater than x
```

`elif` allows for multiple evaluations/branches.

```python
x = 5
y = 10
z = 20

# The elif statement allows for the checking of more conditions.
if x > y:
print("x is greater than y and z")
elif y > z:
print("y is greater than x and z")
else:
print("z is great than x and y")
...
>>> z is great than x and y
```

[Boolen operations][boolean operations] and [comparisons][comparisons] can be combined with conditionals for more complex testing:

```python

>>> def classic_fizzbuzz(number):
if number % 3 == 0 and number % 5 == 0:
return 'FizzBuzz!'
elif number % 5 == 0:
return 'Buzz!'
elif number % 3 == 0:
return 'Fizz!'
else:
return str(number)

>>> classic_fizzbuzz(15)
'FizzBuzz!'

>>> classic_fizzbuzz(13)
'13'
```

[if statement]: https://docs.python.org/3/reference/compound_stmts.html#the-if-statement
[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools
[truth value testing]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing
[boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
[comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons
20 changes: 12 additions & 8 deletions concepts/conditionals/links.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
[
{
"url": "http://example.com/",
"description": "TODO: add new link (above) and write a short description here of the resource."
"url": "https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools",
"description": "Python Docs: Control flow tools."
},
{
"url": "http://example.com/",
"description": "TODO: add new link (above) and write a short description here of the resource."
"url": "https://docs.python.org/3/library/stdtypes.html#truth-value-testing",
"description": "Python Docs: Truth value testing."
},
{
"url": "http://example.com/",
"description": "TODO: add new link (above) and write a short description here of the resource."
"url": "https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not",
"description": "Python Docs: Standard Types - boolean operations."
},
{
"url": "http://example.com/",
"description": "TODO: add new link (above) and write a short description here of the resource."
"url": "https://docs.python.org/3/library/stdtypes.html#comparisons",
"description": "Python Docs: Comparisons."
},
{
"url": "https://realpython.com/python-conditional-statements/",
"description": "Real Python: Conditional statements in Python."
}
]
Loading