From 57b18e3577a8c9b86ab98e87e3af59f4b6114aa9 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 15 May 2026 01:25:58 -0700 Subject: [PATCH 1/4] Corrected typos, formatting, and grammar issues for basics, conditionals, and list-methods. --- concepts/basics/about.md | 67 ++++++++------ concepts/basics/introduction.md | 44 +++++---- concepts/conditionals/about.md | 90 +++++++++---------- concepts/conditionals/introduction.md | 20 ++--- concepts/list-methods/about.md | 5 +- .../.docs/introduction.md | 17 ++-- 6 files changed, 130 insertions(+), 113 deletions(-) diff --git a/concepts/basics/about.md b/concepts/basics/about.md index 71f30524c4d..0f2de695ed1 100644 --- a/concepts/basics/about.md +++ b/concepts/basics/about.md @@ -102,7 +102,7 @@ MY_FIRST_CONSTANT = "Some other value" ## Functions -In Python, units of functionality are encapsulated in [_functions._][functions], which are themselves [objects][objects] (_it's [turtles all the way down][turtles all the way down]_). +In Python, units of functionality are encapsulated in [_functions_][functions], which are themselves [objects][objects] (_it's [turtles all the way down][turtles all the way down]_). Functions can be executed by themselves, passed as arguments to other functions, nested, or bound to a class. When functions are bound to a [class][classes] name, they're referred to as [methods][method objects]. @@ -114,7 +114,7 @@ Statements for the _body_ of the function begin on the line following `def` and ```python -# The body of a function is indented by 2 spaces, & prints the sum of the numbers. +# The body of a function is indented by 2 spaces & prints the sum of the numbers. def add_two_numbers(number_one, number_two): total = number_one + number_two print(total) @@ -126,7 +126,7 @@ def add_two_numbers(number_one, number_two): # Inconsistent indentation in your code blocks will raise an error. >>> def add_three_numbers_misformatted(number_one, number_two, number_three): ... result = number_one + number_two + number_three # This was indented by 4 spaces. -... print(result) #this was only indented by 3 spaces +... print(result) # <--This was only indented by 3 spaces. ... ... File "", line 3 @@ -157,7 +157,7 @@ def add_two_numbers(number_one, number_two): ``` Functions that do not have an _explicit_ expression following a `return` will _implicitly_ return the [`None`][none] object. -The details of `None` will be covered in a later exercise. +The details of `None` will be covered in a later concept. For the purposes of this exercise and explanation, `None` is a placeholder that represents nothing, or null: @@ -208,7 +208,7 @@ Dot (`.`) notation is used for calling functions defined inside a class or modul ```python >>> def raise_to_power(number, power): - return number ** power +... return number ** power ... >>> raise_to_power(3,3) # Invoking the function with the arguments 3 and 3. @@ -225,12 +225,12 @@ TypeError: raise_to_power() missing 1 required positional argument: 'power' # Calling methods or functions in classes and modules. >>> start_text = "my silly sentence for examples." ->>> str.upper(start_text) # Calling the upper() method from the built-in str class on start_text. +>>> str.upper(start_text) # <--Calling the upper() method from the built-in str class on start_text. 'MY SILLY SENTENCE FOR EXAMPLES.' # Because a string is an instance of the str class, methods can also be called on them "directly". >>> start_text = "my silly sentence for examples." ->>> start_text.upper() # Calling the upper() method on start_text directly. +>>> start_text.upper() # <--Calling the upper() method on start_text directly. 'MY SILLY SENTENCE FOR EXAMPLES.' # Alternatively, we can skip the variable assignment (although this gets messy quick). @@ -239,9 +239,8 @@ TypeError: raise_to_power() missing 1 required positional argument: 'power' # Importing the math module -import math - ->>> math.pow(2,4) # Calling the pow() function from the math module +>>> import math +>>> math.pow(2,4) # <--Calling the pow() function from the math module. 16.0 ``` @@ -273,14 +272,18 @@ Docstrings are declared using triple double quotes (""") indented at the same le ```python +# An example from PEP257 of a multi-line docstring +# reformatted to use Google style non-type hinted docstrings. +# Some additional details can be found in the Sphinx documentation: +# https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#getting-started -# An example from PEP257 of a multi-line docstring. def complex(real=0.0, imag=0.0): """Form a complex number. - Keyword arguments: - real -- the real part (default 0.0) - imag -- the imaginary part (default 0.0) + Keyword Arguments: + real (float): The real part of the number (default 0.0) + imag (float): The imaginary part of the number (default 0.0) + """ if imag == 0.0 and real == 0.0: @@ -297,31 +300,38 @@ Testing and `doctest` will be covered in a later concept. ```python -# An example on a user-defined function. +# An example on a user-defined function using a Google style docstring. >>> def raise_to_power(number, power): - """Raise a number to an arbitrary power. - - :param number: int the base number. - :param power: int the power to raise the base number to. - :return: int - number raised to the specified power. + """Raise a number to an arbitrary power. + + Parameters: + number (int): The base number. + power (int): The power to raise the base number to. + + Returns: + int: The number raised to the specified power. + + Takes a number and raises it to the specified power, returning the result. - Takes a number and raises it to the specified power, returning the result. - """ + """ - return number ** power + return number ** power ... # Calling the .__doc__ attribute of the function and printing the result. >>> print(raise_to_power.__doc__) Raise a number to an arbitrary power. - :param number: int the base number. - :param power: int the power to raise the base number to. - :return: int - number raised to the specified power. +Parameters: + number (int): The base number. + power (int): The power to raise the base number to. - Takes a number and raises it to the specified power, returning the result. +Returns: + int: The number raised to the specified power. +Takes a number and raises it to the specified power, returning the result. +... # Printing the __doc__ attribute of the built-in type: str. >>> print(str.__doc__) @@ -333,10 +343,11 @@ errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). -encoding defaults to sys.getdefaultencoding(). +encoding defaults to 'utf-8'. errors defaults to 'strict'. ``` + [PEP257]: https://www.python.org/dev/peps/pep-0257/ [calls]: https://docs.python.org/3/reference/expressions.html#calls [classes]: https://docs.python.org/3/reference/datamodel.html#classes diff --git a/concepts/basics/introduction.md b/concepts/basics/introduction.md index d44e6c9fd07..cb61a0184ab 100644 --- a/concepts/basics/introduction.md +++ b/concepts/basics/introduction.md @@ -25,8 +25,8 @@ A name can be reassigned (or re-bound) to different values (different object typ ```python ->>> my_first_variable = 1 # my_first_variable bound to an integer object of value one. ->>> my_first_variable = 2 # my_first_variable re-assigned to integer value 2. +>>> my_first_variable = 1 # <--my_first_variable bound to an integer object of value one. +>>> my_first_variable = 2 # <--my_first_variable re-assigned to integer value 2. >>> print(type(my_first_variable)) @@ -34,11 +34,11 @@ A name can be reassigned (or re-bound) to different values (different object typ >>> print(my_first_variable) 2 ->>> my_first_variable = "Now, I'm a string." # You may re-bind a name to a different object type and value. +>>> my_first_variable = "Now, I'm a string." # <--You may re-bind a name to a different object type and value. >>> print(type(my_first_variable)) ->>> my_first_variable = 'You can call me "str".' #<-- Strings can be declared using single or double quote marks. +>>> my_first_variable = 'You can call me "str".' # <--Strings can be declared using single or double quote marks. >>> print(my_first_variable) You can call me "str". ``` @@ -60,7 +60,7 @@ Statements for the _body_ of the function begin on the line following `def` and ```python -# The body of this function is indented by 2 spaces,& prints the sum of the numbers. +# The body of this function is indented by 2 spaces & prints the sum of the numbers. def add_two_numbers(number_one, number_two): total = number_one + number_two print(total) @@ -72,7 +72,7 @@ def add_two_numbers(number_one, number_two): # Inconsistent indentation in your code blocks will raise an error. >>> def add_three_numbers_misformatted(number_one, number_two, number_three): ... result = number_one + number_two + number_three # This was indented by 4 spaces. -... print(result) #this was only indented by 3 spaces +... print(result) # <--This was only indented by 3 spaces. ... ... File "", line 3 @@ -104,12 +104,11 @@ def add_two_numbers(number_one, number_two): Functions that do not have an _explicit_ expression following a `return` will _implicitly_ return the [`None`][none] object. -The details of `None` will be covered in a later exercise. +The details of `None` will be covered in a later concept. For the purposes of this exercise and explanation, `None` is a placeholder that represents nothing, or null: ```python - # This function will return `None` def square_a_number(number): square = number * number @@ -131,8 +130,7 @@ Functions that omit `return` will also _implicitly_ return the [`None`][none] o This means that if you do not use `return` in a function, Python will return the `None` object for you. ```python - -# This function omits a return keyword altogether +# This function omits a return keyword altogether. def add_two_numbers(number_one, number_two): result = number_one + number_two @@ -158,29 +156,35 @@ Each line of a comment block must start with the `#` character. ## Docstrings The first statement of a function body can optionally be a [_docstring_][docstring], which concisely summarizes the function or object's purpose. -Docstring conventions are laid out in [PEP257][pep257]. +Docstrings are read by automated documentation tools such as [Sphinx][sphinx] and are returned by calling the special attribute `.__doc__` on the function, method, or class name. +General docstring conventions are laid out in [PEP257][pep257], but exact formats will vary by project and team. Docstrings are declared using triple double quotes (""") indented at the same level as the code block: ```python - -# An example from PEP257 of a multi-line docstring. +# An example from PEP257 of a multi-line docstring +# reformatted to use Google style non-type hinted docstrings. +# Some additional details can be found in the Sphinx documentation: +# https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#getting-started def complex(real=0.0, imag=0.0): """Form a complex number. - Keyword arguments: - real -- the real part (default 0.0) - imag -- the imaginary part (default 0.0) + Keyword Arguments: + real (float): The real part of the number (default 0.0) + imag (float): The imaginary part of the number (default 0.0) + """ if imag == 0.0 and real == 0.0: return complex_zero - ``` -[pep257]: https://www.python.org/dev/peps/pep-0257/ +Docstrings can also function as [lightweight unit tests][doctests], which will be covered in a later concept. + + [comments]: https://realpython.com/python-comments-guide/#python-commenting-basics [docstring]: https://docs.python.org/3/tutorial/controlflow.html#tut-docstrings +[doctests]: https://docs.python.org/3/library/doctest.html [duck typing]: https://en.wikipedia.org/wiki/Duck_typing [dynamic typing in python]: https://stackoverflow.com/questions/11328920/is-python-strongly-typed [everythings an object]: https://docs.python.org/3/reference/datamodel.html @@ -190,6 +194,8 @@ def complex(real=0.0, imag=0.0): [module]: https://docs.python.org/3/tutorial/modules.html [none]: https://docs.python.org/3/library/constants.html [parameters]: https://docs.python.org/3/glossary.html#term-parameter +[pep257]: https://www.python.org/dev/peps/pep-0257/ [return]: https://docs.python.org/3/reference/simple_stmts.html#return -[type hints]: https://docs.python.org/3/library/typing.html [significant indentation]: https://docs.python.org/3/reference/lexical_analysis.html#indentation +[sphinx]: https://www.sphinx-doc.org/en/master/usage/index.html +[type hints]: https://docs.python.org/3/library/typing.html diff --git a/concepts/conditionals/about.md b/concepts/conditionals/about.md index 2060905b335..33592f8c8ec 100644 --- a/concepts/conditionals/about.md +++ b/concepts/conditionals/about.md @@ -57,18 +57,17 @@ else: [Boolean 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: - say = 'FizzBuzz!' - elif number % 5 == 0: - say = 'Buzz!' - elif number % 3 == 0: - say = 'Fizz!' - else: - say = str(number) - - return say +... if number % 3 == 0 and number % 5 == 0: +... say = 'FizzBuzz!' +... elif number % 5 == 0: +... say = 'Buzz!' +... elif number % 3 == 0: +... say = 'Fizz!' +... else: +... say = str(number) +... +... return say >>> classic_fizzbuzz(15) 'FizzBuzz!' @@ -83,14 +82,14 @@ However, re-writing in this way might obscure that the conditions are intended t ```python >>> def classic_fizzbuzz(number): - if number % 3 == 0 and number % 5 == 0: - return 'FizzBuzz!' - if number % 5 == 0: - return 'Buzz!' - if number % 3 == 0: - return 'Fizz!' - - return str(number) +... if number % 3 == 0 and number % 5 == 0: +... return 'FizzBuzz!' +... if number % 5 == 0: +... return 'Buzz!' +... if number % 3 == 0: +... return 'Fizz!' +... +... return str(number) >>> classic_fizzbuzz(15) 'FizzBuzz!' @@ -102,19 +101,20 @@ However, re-writing in this way might obscure that the conditions are intended t Conditionals can also be nested. + ```python >>> def driving_status(driver_age, test_score): - if test_score >= 80: - if 18 > driver_age >= 16: - status = "Student driver, needs supervision." - elif driver_age == 18: - status = "Permitted driver, on probation." - elif driver_age > 18: - status = "Fully licensed driver." - else: - status = "Unlicensed!" - - return status +... if test_score >= 80: +... if 18 > driver_age >= 16: +... status = "Student driver, needs supervision." +... elif driver_age == 18: +... status = "Permitted driver, on probation." +... elif driver_age > 18: +... status = "Fully licensed driver." +... else: +... status = "Unlicensed!" +... +... return status >>> driving_status(63, 78) @@ -130,13 +130,13 @@ Conditionals can also be nested. ## 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 `` if `` else ``. +These take the form of ` if else `. 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) +>>> def just_the_buzz(number): +... return 'Buzz!' if number % 5 == 0 else str(number) >>> just_the_buzz(15) 'Buzz!' @@ -152,29 +152,29 @@ Objects that are evaluated in this fashion are considered "truthy" or "falsy", a ```python >>> def truthy_test(thing): - if thing: - print('This is Truthy.') - else: - print("Nope. It's Falsey.") +... if thing: +... print('This is Truthy.') +... else: +... print('Nope. It's Falsy.') -# Empty container objects are considered Falsey. +# Empty container objects are considered Falsy. >>> truthy_test([]) -Nope. It's Falsey. +'Nope. It's Falsy.' >>> truthy_test(['bear', 'pig', 'giraffe']) -This is Truthy. +'This is Truthy.' -# Empty strings are considered Falsey. +# Empty strings are considered Falsy. >>> truthy_test('') -Nope. It's Falsey. +'Nope. It's Falsy.' >>> truthy_test('yes') -This is Truthy. +'This is Truthy.' -# 0 is also considered Falsey. +# 0 is also considered Falsy. >>> truthy_test(0) -Nope. It's Falsey. +'Nope. It's Falsy.' ``` [boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not diff --git a/concepts/conditionals/introduction.md b/concepts/conditionals/introduction.md index ee1d4336207..425ef93f795 100644 --- a/concepts/conditionals/introduction.md +++ b/concepts/conditionals/introduction.md @@ -58,16 +58,16 @@ else: ```python >>> def classic_fizzbuzz(number): - if number % 3 == 0 and number % 5 == 0: - say = 'FizzBuzz!' - elif number % 5 == 0: - say = 'Buzz!' - elif number % 3 == 0: - say = 'Fizz!' - else: - say = str(number) - - return say +... if number % 3 == 0 and number % 5 == 0: +... say = 'FizzBuzz!' +... elif number % 5 == 0: +... say = 'Buzz!' +... elif number % 3 == 0: +... say = 'Fizz!' +... else: +... say = str(number) +... +... return say >>> classic_fizzbuzz(15) 'FizzBuzz!' diff --git a/concepts/list-methods/about.md b/concepts/list-methods/about.md index 1c9686360d4..00b41f325e5 100644 --- a/concepts/list-methods/about.md +++ b/concepts/list-methods/about.md @@ -11,7 +11,7 @@ Lists support both [common][common sequence operations] and [mutable][mutable se Python provides many useful [methods][list-methods] for working with lists. Because lists are mutable, list-methods **alter the original list object** passed into the method. -If mutation is undesirable, a `shallow copy` (_at minimum__) of the original `list` needs to be made via `slice` or `.copy()`. +If mutation is undesirable, a `shallow copy` (_at minimum_) of the original `list` needs to be made via `slice` or `.copy()`. ## Adding Items @@ -47,7 +47,8 @@ If `` is greater than the final index on the list, the item will be added ``` An `iterable` can be _combined_ with an existing list (concatenating the two) via `.extend()`. -`.extend()` will _unpack_ the supplied iterable, adding its elements in the same order to the end of the target list (_using `.append()` in this circumstance would add the entire iterable as a **single item**._). +`.extend()` will _unpack_ the supplied iterable, adding its elements in the same order to the end of the target list. +Using `.append()` in this circumstance would add the entire iterable as a _**single item**_. ```python diff --git a/exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md b/exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md index 166063057d6..8f06aed4004 100644 --- a/exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md +++ b/exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md @@ -141,8 +141,7 @@ Functions that omit `return` will also _implicitly_ return the [`None`][none] o This means that if you do not use `return` in a function, Python will return the `None` object for you. ```python - -# This function omits a return keyword altogether +# This function omits a return keyword altogether. def add_two_numbers(number_one, number_two): result = number_one + number_two @@ -165,10 +164,10 @@ Dot (`.`) notation is used for calling functions defined inside a class or modul ```python >>> def raise_to_power(number, power): - return number ** power +... return number ** power ... ->>> raise_to_power(3,3) # Invoking the function with the arguments 3 and 3. +>>> raise_to_power(3,3) # <--Invoking the function with the arguments 3 and 3. 27 @@ -182,14 +181,14 @@ TypeError: raise_to_power() missing 1 required positional argument: 'power' # Calling methods or functions in classes and modules. >>> start_text = "my silly sentence for examples." ->>> str.upper(start_text) # Calling the upper() method from the built-in str class on start_text. +>>> str.upper(start_text) # <--Calling the upper() method from the built-in str class on start_text. 'MY SILLY SENTENCE FOR EXAMPLES.' # Importing the math module -import math +>>> import math ->>> math.pow(2,4) # Calling the pow() function from the math module +>>> math.pow(2,4) # <--Calling the pow() function from the math module. 16.0 ``` @@ -237,8 +236,7 @@ Docstrings can also function as [lightweight unit tests][doctests], which will b ```python -# An example on a user-defined function. -# This uses Google style docstrings. +# An example on a user-defined function using a Google style docstring. >>> def raise_to_power(number, power): """Raise a number to an arbitrary power. @@ -270,6 +268,7 @@ Returns: Takes a number and raises it to the specified power, returning the result. ``` + [calls]: https://docs.python.org/3/reference/expressions.html#calls [comments]: https://realpython.com/python-comments-guide/#python-commenting-basics [docstring]: https://docs.python.org/3/tutorial/controlflow.html#tut-docstrings From 812b2c7f63a2a387a6da40ecd4c9ee569a5bbfbd Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 15 May 2026 12:42:38 -0700 Subject: [PATCH 2/4] Further corrections from code review. --- concepts/basics/about.md | 12 ++++----- concepts/conditionals/about.md | 37 ++++++++++----------------- concepts/conditionals/introduction.md | 20 +++++++-------- 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/concepts/basics/about.md b/concepts/basics/about.md index 0f2de695ed1..f6edd803541 100644 --- a/concepts/basics/about.md +++ b/concepts/basics/about.md @@ -55,8 +55,8 @@ For example, `my_first_variable` can be re-assigned many times using `=`, and ca ```python ->>> my_first_variable = 1 # my_first_variable bound to an integer object of value one. ->>> my_first_variable = 2 # my_first_variable re-assigned to integer value 2. +>>> my_first_variable = 1 # <--my_first_variable bound to an integer object of value one. +>>> my_first_variable = 2 # <--my_first_variable re-assigned to integer value 2. >>> print(type(my_first_variable)) @@ -64,16 +64,16 @@ For example, `my_first_variable` can be re-assigned many times using `=`, and ca >>> print(my_first_variable) 2 ->>> my_first_variable = "Now, I'm a string." # You may re-bind a name to a different object type and value. +>>> my_first_variable = "Now, I'm a string." # <--You may re-bind a name to a different object type and value. >>> print(type(my_first_variable)) ->>> my_first_variable = 'You can call me "str".' # Strings can be declared using single or double quote marks. +>>> my_first_variable = 'You can call me "str".' # <--Strings can be declared using single or double quote marks. >>> print(my_first_variable) You can call me "str". -import collections ->>> my_first_variable = collections.Counter([1,1,2,3,3,3,4,5,6,7]) # Now my_first_variable has been re-bound to a Counter object. +>>> import collections +>>> my_first_variable = collections.Counter([1,1,2,3,3,3,4,5,6,7]) # <--Now my_first_variable has been re-bound to a Counter object. >>> print(type(my_first_variable)) diff --git a/concepts/conditionals/about.md b/concepts/conditionals/about.md index 33592f8c8ec..01fda104ceb 100644 --- a/concepts/conditionals/about.md +++ b/concepts/conditionals/about.md @@ -57,17 +57,7 @@ else: [Boolean 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: -... say = 'FizzBuzz!' -... elif number % 5 == 0: -... say = 'Buzz!' -... elif number % 3 == 0: -... say = 'Fizz!' -... else: -... say = str(number) -... -... return say +>>> >>> classic_fizzbuzz(15) 'FizzBuzz!' @@ -83,13 +73,14 @@ However, re-writing in this way might obscure that the conditions are intended t ```python >>> def classic_fizzbuzz(number): ... if number % 3 == 0 and number % 5 == 0: -... return 'FizzBuzz!' -... if number % 5 == 0: -... return 'Buzz!' -... if number % 3 == 0: -... return 'Fizz!' -... -... return str(number) +... say = 'FizzBuzz!' +... elif number % 5 == 0: +... say = 'Buzz!' +... elif number % 3 == 0: +... say = 'Fizz!' +... else: +... say = str(number) +... return say >>> classic_fizzbuzz(15) 'FizzBuzz!' @@ -111,8 +102,8 @@ Conditionals can also be nested. ... status = "Permitted driver, on probation." ... elif driver_age > 18: ... status = "Fully licensed driver." -... else: -... status = "Unlicensed!" +... else: +... status = "Unlicensed!" ... ... return status @@ -155,7 +146,7 @@ Objects that are evaluated in this fashion are considered "truthy" or "falsy", a ... if thing: ... print('This is Truthy.') ... else: -... print('Nope. It's Falsy.') +... print("Nope. It's Falsy.") # Empty container objects are considered Falsy. @@ -167,14 +158,14 @@ Objects that are evaluated in this fashion are considered "truthy" or "falsy", a # Empty strings are considered Falsy. >>> truthy_test('') -'Nope. It's Falsy.' +"Nope. It's Falsy." >>> truthy_test('yes') 'This is Truthy.' # 0 is also considered Falsy. >>> truthy_test(0) -'Nope. It's Falsy.' +"Nope. It's Falsy." ``` [boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not diff --git a/concepts/conditionals/introduction.md b/concepts/conditionals/introduction.md index 425ef93f795..ba4f098493d 100644 --- a/concepts/conditionals/introduction.md +++ b/concepts/conditionals/introduction.md @@ -58,16 +58,15 @@ else: ```python >>> def classic_fizzbuzz(number): -... if number % 3 == 0 and number % 5 == 0: -... say = 'FizzBuzz!' -... elif number % 5 == 0: -... say = 'Buzz!' -... elif number % 3 == 0: -... say = 'Fizz!' -... else: -... say = str(number) -... -... return say +... if number % 3 == 0 and number % 5 == 0: +... say = 'FizzBuzz!' +... elif number % 5 == 0: +... say = 'Buzz!' +... elif number % 3 == 0: +... say = 'Fizz!' +... else: +... say = str(number) +... return say >>> classic_fizzbuzz(15) 'FizzBuzz!' @@ -76,6 +75,7 @@ else: '13' ``` + [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 [control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools From f0651547d37af369d3dc961570d5cb704bd5c88b Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 15 May 2026 13:32:31 -0700 Subject: [PATCH 3/4] More typos. --- concepts/basics/about.md | 4 ++-- concepts/conditionals/about.md | 30 ++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/concepts/basics/about.md b/concepts/basics/about.md index f6edd803541..6f932bfd16f 100644 --- a/concepts/basics/about.md +++ b/concepts/basics/about.md @@ -55,8 +55,8 @@ For example, `my_first_variable` can be re-assigned many times using `=`, and ca ```python ->>> my_first_variable = 1 # <--my_first_variable bound to an integer object of value one. ->>> my_first_variable = 2 # <--my_first_variable re-assigned to integer value 2. +>>> my_first_variable = 1 # my_first_variable bound to an integer object of value one. +>>> my_first_variable = 2 # my_first_variable re-assigned to integer value 2. >>> print(type(my_first_variable)) diff --git a/concepts/conditionals/about.md b/concepts/conditionals/about.md index 01fda104ceb..c184a4e5b0e 100644 --- a/concepts/conditionals/about.md +++ b/concepts/conditionals/about.md @@ -56,9 +56,20 @@ else: [Boolean operations][boolean operations] and [comparisons][comparisons] can be combined with conditionals for more complex testing: -```python ->>> +```python +>>> def classic_fizzbuzz(number): +... if number % 3 == 0 and number % 5 == 0: +... say = 'FizzBuzz!' +... elif number % 5 == 0: +... say = 'Buzz!' +... elif number % 3 == 0: +... say = 'Fizz!' +... else: +... say = str(number) +... +... return say + >>> classic_fizzbuzz(15) 'FizzBuzz!' @@ -73,14 +84,13 @@ However, re-writing in this way might obscure that the conditions are intended t ```python >>> def classic_fizzbuzz(number): ... if number % 3 == 0 and number % 5 == 0: -... say = 'FizzBuzz!' -... elif number % 5 == 0: -... say = 'Buzz!' -... elif number % 3 == 0: -... say = 'Fizz!' -... else: -... say = str(number) -... return say +... return 'FizzBuzz!' +... if number % 5 == 0: +... return 'Buzz!' +... if number % 3 == 0: +... return 'Fizz!' +... +... return str(number) >>> classic_fizzbuzz(15) 'FizzBuzz!' From 6ef4d32583edb44945c3aafd4b6ad2742a453902 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Fri, 15 May 2026 13:33:57 -0700 Subject: [PATCH 4/4] Fixed double quote issue. --- concepts/conditionals/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/conditionals/about.md b/concepts/conditionals/about.md index c184a4e5b0e..8891683f791 100644 --- a/concepts/conditionals/about.md +++ b/concepts/conditionals/about.md @@ -161,7 +161,7 @@ Objects that are evaluated in this fashion are considered "truthy" or "falsy", a # Empty container objects are considered Falsy. >>> truthy_test([]) -'Nope. It's Falsy.' +"Nope. It's Falsy." >>> truthy_test(['bear', 'pig', 'giraffe']) 'This is Truthy.'