← Back to challenges

Black Holes

PythonHardphysicsmath

Instructions

A black hole is a region of spacetime where gravity is so strong that nothing⁠ — no particles or even electromagnetic radiation such as light ⁠— can escape from it.

The Schwarzschild radius (sometimes historically referred to as the gravitational radius) is a physical parameter that shows up in the Schwarzschild solution to Einstein's field equations, corresponding to the radius defining the event horizon of a Schwarzschild black hole.

Objective

Create a function that takes the name and the mass (in solar masses) of a black hole as an argument and returns the Schwarzschild radius, the Schwarzschild density and the type of black hole.

Consider:

c = 299792458
G = 6.67430e-11
pi = 3.141592
sun_mass = 1.99e30

Types of black holes:

TypeSolar Mass
Supermassive black hole> 1e5
Intermediate-mass black hole> 1e2 and <= 1e5
Stellar black hole> 1e-1 and <= 1e2
Micro black hole<= 1e-1

Examples

black_holes("APM 08279+5255", 2.3e10) ➞

---------- Black Hole APM 08279+5255 ----------

Schwarzschild radius = 6.80e+13 m
Schwarzschild density = 3.48e-02 kg/m3
Type of black hole = Supermassive black hole

black_holes("Messier 87", 7.22e9) ➞

---------- Black Hole Messier 87 ----------

Schwarzschild radius = 2.13e+13 m
Schwarzschild density = 3.53e-01 kg/m3
Type of black hole = Supermassive black hole

black_holes("Messier 110", 1.45e4) ➞

---------- Black Hole Messier 110 ----------

Schwarzschild radius = 4.29e+07 m
Schwarzschild density = 8.75e+10 kg/m3
Type of black hole = Intermediate-mass black hole

Notes

Express the Schwarzschild radius and the Schwarzschild density using scientific notation with two decimal places.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.