CS50P 'Einstein' Problem Teaches Python Variables and E=mc² Calculation
A developer advocate walking through Harvard's CS50P course has shared insights from solving the 'Einstein' problem in Problem Set 0, which involves coding Einstein's mass-energy equivalence formula E=mc². The exercise requires learners to accept a user-input mass value, assign the speed of light as a variable, and multiply them correctly to compute energy. A key detail highlighted is that the speed of light must be squared, meaning it is multiplied by itself in the calculation. The author also recaps a prior lesson on Python's chained string replacement method, showing how multiple substitutions can be performed in a single line of code. The series aims to guide learners through CS50P problems with hints rather than direct answers, encouraging independent problem-solving.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in