From 8ad9e5323d12ef9754cad0f5e214b333883502e9 Mon Sep 17 00:00:00 2001 From: baozi Date: Sun, 7 Aug 2022 14:50:30 -0400 Subject: [PATCH 1/9] Created type error in python errors entry --- content/python/concepts/errors/errors.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index b833374db49..8a471df024e 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -79,6 +79,17 @@ import notamodule ModuleNotFoundError: No module named 'notamodule' ``` +### Type Error + +`TypeError` is thrown when a function's argument is of an inappropriate type. + +```error +Traceback (most recent call last): +File "script.py", line 1, in +max(True) +TypeError: 'bool' object is not iterable +``` + ### Zero Division Error `ZeroDivisionError` is thrown when the second operator in the division is zero. From 6f3c60931de31eb24afc2ae4577214d2caef6517 Mon Sep 17 00:00:00 2001 From: baozi Date: Sun, 7 Aug 2022 17:47:44 -0400 Subject: [PATCH 2/9] Corrected the description for value error --- content/python/concepts/errors/errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 8a471df024e..16d8a56a166 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -37,7 +37,7 @@ Even if a statement or expression is syntactically correct, it may cause an erro ### Value Error -`ValueError` is thrown when a function's argument is of an inappropriate type. +`ValueError` is thrown when a function's argument is of the correct type, but an inapprpriate value, such as being out of range. ```error Traceback (most recent call last): From 26f28443411ad1405c17383d0fff7f6a077adfd3 Mon Sep 17 00:00:00 2001 From: baozi Date: Sun, 7 Aug 2022 14:50:30 -0400 Subject: [PATCH 3/9] Created type error in python errors entry --- content/python/concepts/errors/errors.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index b833374db49..8a471df024e 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -79,6 +79,17 @@ import notamodule ModuleNotFoundError: No module named 'notamodule' ``` +### Type Error + +`TypeError` is thrown when a function's argument is of an inappropriate type. + +```error +Traceback (most recent call last): +File "script.py", line 1, in +max(True) +TypeError: 'bool' object is not iterable +``` + ### Zero Division Error `ZeroDivisionError` is thrown when the second operator in the division is zero. From 29cc43d30d96e9b641922dc1a866e07a1abc2448 Mon Sep 17 00:00:00 2001 From: baozi Date: Sun, 7 Aug 2022 17:47:44 -0400 Subject: [PATCH 4/9] Corrected the description for value error --- content/python/concepts/errors/errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 8a471df024e..16d8a56a166 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -37,7 +37,7 @@ Even if a statement or expression is syntactically correct, it may cause an erro ### Value Error -`ValueError` is thrown when a function's argument is of an inappropriate type. +`ValueError` is thrown when a function's argument is of the correct type, but an inapprpriate value, such as being out of range. ```error Traceback (most recent call last): From 471809d70a5dc3ccb4a035a598ee5a11a4f49cdb Mon Sep 17 00:00:00 2001 From: baozi Date: Wed, 10 Aug 2022 18:58:08 -0400 Subject: [PATCH 5/9] Replaced error codeblocks with shell codeblocks to match markdown guide --- content/python/concepts/errors/errors.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 16d8a56a166..15a37b16b7f 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -18,7 +18,7 @@ There are (at least) two distinguishable kinds of errors in Python: syntax error Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python: -```error +```shell File "script.py", line 1 while True print("Hello world!") ^ @@ -39,7 +39,7 @@ Even if a statement or expression is syntactically correct, it may cause an erro `ValueError` is thrown when a function's argument is of the correct type, but an inapprpriate value, such as being out of range. -```error +```shell Traceback (most recent call last): File "script.py", line 1, in int('xyz') @@ -50,7 +50,7 @@ ValueError: invalid literal for int() with base 10: 'xyz' `NameError` is thrown when an object could not be found. -```error +```shell Traceback (most recent call last): File "script.py", line 1, in age @@ -61,7 +61,7 @@ NameError: name 'age' is not defined `IndexError` is thrown when trying to access an item at an invalid index. -```error +```shell Traceback (most recent call last): File "script.py", line 1, in employees[3] @@ -72,7 +72,7 @@ IndexError: list index out of range `ModuleNotFoundError` is thrown when a module could not be found. -```error +```shell Traceback (most recent call last): File "script.py", line 1, in import notamodule @@ -83,7 +83,7 @@ ModuleNotFoundError: No module named 'notamodule' `TypeError` is thrown when a function's argument is of an inappropriate type. -```error +```shell Traceback (most recent call last): File "script.py", line 1, in max(True) @@ -94,7 +94,7 @@ TypeError: 'bool' object is not iterable `ZeroDivisionError` is thrown when the second operator in the division is zero. -```error +```shell Traceback (most recent call last): File "script.py", line 1, in ratio = 100 / 0 From 2d93a077ad63aeb54b94d7fbaaa094b1eafb51c6 Mon Sep 17 00:00:00 2001 From: baozi Date: Wed, 10 Aug 2022 19:20:46 -0400 Subject: [PATCH 6/9] Updated description to be under 150 characters --- content/python/concepts/errors/errors.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 15a37b16b7f..5fbecdc82f9 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -1,6 +1,6 @@ --- Title: 'Errors' -Description: 'There are (at least) two distinguishable kinds of errors in Python: syntax errors and exceptions. Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python: error File "script.py", line 1 while True print("Hello world!") ^ SyntaxError: invalid syntax' +Description: 'There are two main kinds of errors in Python: syntax errors and exceptions. Exceptions are any errors that arise from syntactically correct code. Subjects: - 'Computer Science' - 'Data Science' @@ -27,7 +27,7 @@ SyntaxError: invalid syntax The parser repeats the offending line and displays a little arrow `^` pointing at the earliest point in the line where the error was detected. -The error is caused by (or at least detected at) the token preceding the arrow in the example, the error is detected at the function `print()`, since a colon `:` is missing before it. +The error is caused by (or at least detected at) the token preceding the arrow in the example, the error is detected at the [`print()`](https://www.codecademy.com/resources/docs/python/built-in-functions/print) function, since a colon `:` is missing before it. File name and line number are printed so you know where to look in case the input came from a script. From d64e7415047649148fff92ed9b09f647f252b25e Mon Sep 17 00:00:00 2001 From: baozi Date: Sat, 13 Aug 2022 19:50:14 -0400 Subject: [PATCH 7/9] Corrected description in errors.md --- content/python/concepts/errors/errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 5fbecdc82f9..3ddb4538449 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -1,6 +1,6 @@ --- Title: 'Errors' -Description: 'There are two main kinds of errors in Python: syntax errors and exceptions. Exceptions are any errors that arise from syntactically correct code. +Description: 'There are two main kinds of errors in Python: syntax errors and exceptions. Exceptions are any errors that arise from syntactically correct code.' Subjects: - 'Computer Science' - 'Data Science' From dab04568fc76ba66c08fcc6414bbf59315d69005 Mon Sep 17 00:00:00 2001 From: baozi Date: Tue, 16 Aug 2022 21:39:59 -0400 Subject: [PATCH 8/9] Reworded descriptions to match neutral writing tone --- content/python/concepts/errors/errors.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 3ddb4538449..6bb412dab0e 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -1,6 +1,6 @@ --- Title: 'Errors' -Description: 'There are two main kinds of errors in Python: syntax errors and exceptions. Exceptions are any errors that arise from syntactically correct code.' +Description: 'The two types of errors in Python are syntax errors and exceptions. Exceptions may arise even if the code is syntactically correct.' Subjects: - 'Computer Science' - 'Data Science' @@ -12,11 +12,11 @@ CatalogContent: - 'paths/computer-science' --- -There are (at least) two distinguishable kinds of errors in Python: syntax errors and exceptions. +"The two types of **errors** are syntax errors and exceptions." ## Syntax Errors -Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python: +Syntax errors (also known as parsing errors) occur when a sequence of characters, or tokens, violates the syntax of the Python programming language: ```shell File "script.py", line 1 @@ -29,7 +29,7 @@ The parser repeats the offending line and displays a little arrow `^` pointing a The error is caused by (or at least detected at) the token preceding the arrow in the example, the error is detected at the [`print()`](https://www.codecademy.com/resources/docs/python/built-in-functions/print) function, since a colon `:` is missing before it. -File name and line number are printed so you know where to look in case the input came from a script. +File name and line number are printed to state where the error originated. ## Exceptions From c097860e31b7bb85644697f247e67a3e2ec00327 Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Mon, 22 Aug 2022 16:21:32 -0400 Subject: [PATCH 9/9] Update errors.md --- content/python/concepts/errors/errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/python/concepts/errors/errors.md b/content/python/concepts/errors/errors.md index 6bb412dab0e..6758b88ceea 100644 --- a/content/python/concepts/errors/errors.md +++ b/content/python/concepts/errors/errors.md @@ -12,7 +12,7 @@ CatalogContent: - 'paths/computer-science' --- -"The two types of **errors** are syntax errors and exceptions." +The two types of **errors** in Python are syntax errors and exceptions. ## Syntax Errors