Skip to content

Commit fe34867

Browse files
committed
Create solution for "Learn about types of errors"
1 parent 53f8d6a commit fe34867

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

error.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def main()
2+
a = 6
3+
print("Sum:", a + a)
4+
print("Difference:", a + a)
5+
a *= a
6+
print("To the power of itself:", a)
7+
print("Doubled", a * 2)
8+
9+
10+
if __name__ == "__main__":
11+
main()

error_solution.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def main() # Syntax error
2+
a = 5
3+
print("Sum:", a + a)
4+
print("Tripled:", a / 3) # Semantic error. Meant to be a * 3
5+
a *= a
6+
print("To the power of itself:", a)
7+
print("Doubled", a * 2) # Logic error, a has been changed to be to the power of itself - this is (a^2)*2 not a*2
8+
9+
10+
if __name__ == "__main__":
11+
main()

0 commit comments

Comments
 (0)