ΣνΜDr. Sharon's Math PlatformSyvara Learning
Question Bank › 📘 Undergraduate › Numerical Method with Python (Math & Eng) › Q5

Q5 · Python function compute_errors for absolute and relative error

Errors and Scientific Notation 🟡 Intermediate Coding
Question

Write a Python function compute_errors(true_val, approx_val) that returns:

  1. The absolute error
  2. The relative error (as a decimal)

Test it with:

  • true = $\pi$ (use math.pi), approx = 3.14
  • true = $e$ (use math.e), approx = 2.718

Print results formatted to 6 decimal places.

🔒

Log in to see the worked solution

Enter your email to get started. Your first free solutions in every course unlock as soon as you verify.

Log in or sign up with email
← Previous Next →
Working…