Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFor CS50P’s “Einstein” exercise, convert the entered mass to an integer and multiply it by 300,000,000 twice. That matches the assignment’s integer input and integer output—and avoids adding floating-point approximation where the task does not require fractional values. The arithmetic can be exact for the chosen integer constant, even though the exercise describes the speed of light as approximate.
What the CS50P Einstein exercise asks you to do
The course asks you to create einstein.py, prompt for mass in kilograms as an integer, and print the equivalent energy in joules as an integer. It introduces the equation E = mc² and uses an approximate speed of light of 300,000,000 meters per second. See the official CS50P assignment.
In the equation, E is energy, m is mass, and c is the speed of light. Since c is squared, multiply the mass by 300,000,000 two times. In Python, input returns text, so convert the response to an integer before doing the multiplication:
mass = int(input("Mass: "))
energy = mass * 300_000_000 * 300_000_000
print(energy)
Python permits underscores in integer literals to make long numbers easier to read; they do not change the value. The output is an integer, with no decimal point.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
Why integers fit this calculation
The assignment specifies an integer mass and an integer energy result. Python integers represent whole numbers exactly, and multiplying integer operands produces an exact integer result. That makes integer arithmetic a direct match for the exercise: no conversion to a floating-point value or rounding step is needed.
The manual examples on the assignment page are:
- Mass of 1 kg produces 90,000,000,000,000,000 J.
- Mass of 14 kg produces 1,260,000,000,000,000,000 J.
- Mass of 50 kg produces 4,500,000,000,000,000,000 J.
These are the course’s published examples. The page also points learners to check50 for checking a submission.
Rank #2
Exact code arithmetic is not the same as an exact physical measurement
There are two kinds of precision to keep separate. The multiplication above is exact as integer arithmetic using the integer constant 300,000,000. But CS50P calls that speed of light value approximate, so the computed result should not be described as an exact measurement of the energy of a real object. The code is exact relative to the exercise’s chosen inputs and constant; the physical quantity is modeled using an approximation.
How this differs from floating-point arithmetic
Floating-point numbers are useful when a program needs fractional values, but they have different representation behavior. Python’s tutorial explains that most decimal fractions cannot be represented exactly as binary fractions; Python floats on almost all platforms map to IEEE 754 binary64 values with 53 bits of precision. As a result, a calculation using floats may contain a small representation approximation. See the Python tutorial’s explanation of floating-point arithmetic.
Recommended Free Tools
That does not mean floats are inherently bad or should always be avoided. Use a numeric type according to the values and result a task requires. “Einstein” asks for whole-number input and output, so ordinary integers are simpler and meet the specification without an unnecessary representation change.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.When Decimal might be appropriate instead
Python’s decimal module supports user-adjustable precision and can be useful when decimal equality rules matter, such as in some accounting work. The Python 3.11 documentation gives a default precision of 28 places. That is context for choosing a numeric representation, not a reason to add Decimal to this exercise: the specified values and result are integers. See the Python 3.11 Decimal documentation.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




