# What is an example of a runtime error?

Here’s an example of a runtime error in Python:

```# Runtime Error Example: Division by zero
numerator = 10
denominator = 0
result = numerator / denominator
print(result)
```

In this example, we are attempting to divide the variable `numerator` by zero, which will cause a runtime error. When you run this code, you’ll encounter a `ZeroDivisionError` and the program will stop with an error message indicating that the division by zero is not possible.

Runtime errors occur during the execution of the program and can happen due to various reasons, such as invalid operations, unexpected data types, or accessing elements outside the allowed range.

## What is the example of runtime error and logical error?

Here’s an example of a runtime error and a logical error in Python:

Runtime Error Example:

```# Runtime Error Example: ValueError
num = int(input("Enter a number: "))
print("The square of the number is:", num**2)
```

In this example, the user is prompted to enter a number, which is then converted to an integer using the `int()` function. However, if the user enters a non-numeric value, such as a string or a special character, a `ValueError` will occur during runtime. This is because the `int()` function cannot convert non-numeric values to integers.

Logical Error Example:

```# Logical Error Example: Incorrect calculation
In this example, we attempt to calculate the area of a circle using the formula `2 * 3.14 * radius`. However, the formula is incorrect. The correct formula to calculate the area of a circle is `3.14 * radius**2`. This mistake leads to a logical error in the code, as it will produce an incorrect result for the area of the circle.
• 