Skip to content

Commit 59541f0

Browse files
BethanyGYrahcaz7
andauthored
[None and Random Concepts]: Fixed Typos & Formatting (#4207)
* Fixed typos and formatting for none and random concepts. * Update concepts/none/introduction.md Co-authored-by: Yrahcaz <74512479+Yrahcaz7@users.noreply.github.com> * Update concepts/none/introduction.md Co-authored-by: Yrahcaz <74512479+Yrahcaz7@users.noreply.github.com> * Applied changes from code review. --------- Co-authored-by: Yrahcaz <74512479+Yrahcaz7@users.noreply.github.com>
1 parent 6753e43 commit 59541f0

4 files changed

Lines changed: 38 additions & 31 deletions

File tree

concepts/none/about.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# About
1+
# TODO: Add about for this concept.
2+
23

concepts/none/introduction.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
# Introduction
22

3-
In Python, `None` is frequently used to represent the absence of a value -- a placeholder to define a `null` (empty) variable, object, or argument.
3+
In Python, `None` is frequently used to represent the absence of a value — a placeholder to define a `null` (empty) variable, object, or argument.
4+
5+
If you've heard about or used a `NULL` or `nil` type in another programming language, then this usage of `None` in Python will be familiar to you.
6+
`None` helps you to declare variables or function arguments that you don't yet have values for.
7+
These can then be re-assigned to specific values later as needed:
48

5-
If you've heard about or used a `NULL` or `nil` type in another programming language, then this usage of `None` in Python will be familiar to you. `None` helps you to declare variables or function arguments that you don't yet have values for. These can then be re-assigned to specific values later as needed.
69

710
```python
811
a = None
912
print(a)
1013
#=> None
14+
1115
type(a)
1216
#=> <class 'NoneType'>
1317

14-
# Adding a Default Argument with `None`
18+
# Adding a default argument with `None`
1519
def add_to_todos(new_task, todo_list=None):
16-
if todo_list is None:
17-
todo_list = []
20+
if todo_list is None:
21+
todo_list = []
1822
todo_list.append(new_task)
23+
1924
return todo_list
20-
2125
```
2226

23-
`None` will evaluate to `False` when used in a conditional check, so it is useful for validating the "presence of" or "absence of" a value - _any_ value -- a pattern frequently used when a function or process might hand back an error object or message.
27+
`None` will evaluate to `False` when used in a conditional check, so it is useful for validating the "presence of" or "absence of" a value _any_ value a pattern frequently used when a function or process might hand back an `error`, `object`, or message.
2428

2529
```python
2630
a = None
27-
if a: #=> a will be evaluated to False when its used in a conditional check.
31+
if a: #<-- a will be evaluated to False when it is used in a conditional check.
2832
print("This will not be printed")
2933
```

concepts/random/about.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# About
22

3-
Many programs need (apparently) random values to simulate real-world events.
3+
Many programs need (_seemingly_) random values to simulate real-world events.
44

55
Common, familiar examples include:
6-
- A coin toss: a random value from `('H', 'T')`.
6+
- A coin toss: a random value from `('Heads', 'Tails')`.
77
- The roll of a die: a random integer from 1 to 6.
88
- Shuffling a deck of cards: a random ordering of a card list.
99

@@ -18,7 +18,7 @@ We encourage you to explore the full `random` documentation, as there are many m
1818

1919
~~~~exercism/caution
2020
21-
The `random` module should __NOT__ be used for security and cryptographic applications.
21+
The `random` module should __NOT__ be used for security or cryptographic applications.
2222
2323
Instead, Python provides the [`secrets`][secrets] module.
2424
This is specially optimized for cryptographic security.
@@ -60,17 +60,17 @@ To avoid typing the name of the module, you can import specific functions by nam
6060

6161
# Using choice() to pick Heads or Tails 10 times
6262
>>> tosses = []
63-
>>> for side in range(10):
64-
>>> tosses.append(choice(['H', 'T']))
63+
... for side in range(10):
64+
... tosses.append(choice(['H', 'T']))
6565

6666
>>> print(tosses)
6767
['H', 'H', 'H', 'H', 'H', 'H', 'H', 'T', 'T', 'H']
6868

6969

7070
# Using choices() to pick Heads or Tails 8 times
7171
>>> picks = []
72-
>>> picks.extend(choices(['H', 'T'], k=8))
73-
>>> print(picks)
72+
... picks.extend(choices(['H', 'T'], k=8))
73+
... print(picks)
7474
['T', 'H', 'H', 'T', 'H', 'H', 'T', 'T']
7575
```
7676

@@ -94,8 +94,9 @@ Possible results from `randint()` _include_ the upper bound, so `randint(a, b)`
9494

9595
# Select 10 numbers at random between 0 and 9 two steps apart.
9696
>>> numbers = []
97-
>>> for integer in range(10):
98-
>>> numbers.append(random.randrange(0, 10, 2))
97+
... for integer in range(10):
98+
... numbers.append(random.randrange(0, 10, 2))
99+
99100
>>> print(numbers)
100101
[2, 8, 4, 0, 4, 2, 6, 6, 8, 8]
101102

@@ -108,10 +109,10 @@ Possible results from `randint()` _include_ the upper bound, so `randint(a, b)`
108109

109110
## Working with sequences
110111

111-
The functions in this section assume that you are starting from some [sequence][sequence-types], or other container.
112+
The functions in this section assume that you are starting from some [sequence][sequence-types] or other container.
112113

113114

114-
This will typically be a `list`, or with some limitations a `tuple` or a `set` (_a `tuple` is immutable, and `set` is unordered_).
115+
This will typically be a `list`, or with some limitations, a `tuple` or a `set` (_a `tuple` is immutable, and `set` is unordered_).
115116

116117

117118

@@ -124,9 +125,10 @@ At its simplest, this might be a coin-flip:
124125
# This will pick one of the two values in the list at random 5 separate times
125126
>>> [random.choice(['H', 'T']) for _ in range(5)]
126127
['T', 'H', 'H', 'T', 'H']
128+
```
127129

128-
We could accomplish essentially the same thing using the `choices()` function, supplying a keyword argument with the list length:
129130

131+
We could accomplish essentially the same thing using the `choices()` function, supplying a keyword argument with the list length:
130132

131133
```python
132134
>>> random.choices(['H', 'T'], k=5)

concepts/random/introduction.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Introduction
22

3-
Many programs need (apparently) random values to simulate real-world events.
3+
Many programs need (_seemingly_) random values to simulate real-world events.
44

55
Common, familiar examples include:
6-
- A coin toss: a random value from `('H', 'T')`.
6+
- A coin toss: a random value from `('Heads', 'Tails')`.
77
- The roll of a die: a random integer from 1 to 6.
88
- Shuffling a deck of cards: a random ordering of a card list.
99
- The creation of trees and bushes in a 3-D graphics simulation.
@@ -18,7 +18,7 @@ We encourage you to explore the full [`random`][random] documentation, as there
1818

1919
~~~~exercism/caution
2020
21-
The `random` module should __NOT__ be used for security and cryptographic applications!!
21+
The `random` module should __NOT__ be used for security or cryptographic applications!!
2222
2323
Instead, Python provides the [`secrets`][secrets] module.
2424
This is specially optimized for cryptographic security.
@@ -57,17 +57,17 @@ To avoid typing the name of the module, you can import specific functions by nam
5757

5858
# Using choice() to pick Heads or Tails 10 times
5959
>>> tosses = []
60-
>>> for side in range(10):
61-
>>> tosses.append(choice(['H', 'T']))
60+
... for side in range(10):
61+
... tosses.append(choice(['H', 'T']))
6262

6363
>>> print(tosses)
6464
['H', 'H', 'H', 'H', 'H', 'H', 'H', 'T', 'T', 'H']
6565

6666

6767
# Using choices() to pick Heads or Tails 8 times
6868
>>> picks = []
69-
>>> picks.extend(choices(['H', 'T'], k=8))
70-
>>> print(picks)
69+
... picks.extend(choices(['H', 'T'], k=8))
70+
... print(picks)
7171
['T', 'H', 'H', 'T', 'H', 'H', 'T', 'T']
7272
```
7373

@@ -89,10 +89,10 @@ Possible results from `randint()` _include_ the upper bound, so `randint(a, b)`
8989

9090
## `choice()` and `choices()`
9191

92-
These two functions assume that you are starting from some [sequence][sequence-types], or other container.
93-
This will typically be a `list`, or with some limitations a `tuple` or a `set` (_a `tuple` is immutable, and `set` is unordered_).
92+
These two functions assume that you are starting from some [sequence][sequence-types] or other container.
93+
This will typically be a `list`, or with some limitations, a `tuple` or a `set` (_a `tuple` is immutable, and `set` is unordered_).
9494

95-
The `choice()` function will return one entry chosen at random from a given sequence, and `choices()` will return `k` number of entries chosen at random from a given sequence.
95+
The `choice()` function will return one member chosen at random from a given sequence, and `choices()` will return a specified number of members (`k`) chosen at random from a given sequence.
9696
In the examples shown above, we assumed a fair coin with equal probability of heads or tails, but weights can also be specified.
9797

9898
For example, if a bag contains 10 red balls and 15 green balls, and we would like to pull one out at random:

0 commit comments

Comments
 (0)