Skip navigation
Types of errors in Coding ❌😯
0:00

Types of errors in Coding ❌😯

Types of errors in Coding ❌😯 1. Syntax Error: print("Hello, world!" This code has a missing closing parenthesis, causing a syntax error. 2. Logical Error: def add_numbers(x, y): result = x - y return result print(add_numbers(5, 3)) The function is intended to add numbers but has a subtraction operation, leading to a logical error. 3. Runtime Error: def divide_numbers(x, y): result = x / y return result print(divide_numbers(5, 0)) This code tries to divide by zero, resulting in a runtime error. 4. Semantic Error: def calculate_area(radius): area = 2.14 * radius * radius return area print(calculate_area(5)) While the code runs without errors, it has a semantic error because it uses an incorrect value for π (pi).

Comments

Comments from the original post on Instagram

No comments yet