Challenge - 5 Problems
Scipy Constants Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
Output of accessing a physical constant
What is the output of this code snippet using
scipy.constants?SciPy
from scipy.constants import speed_of_light print(round(speed_of_light, 1))
Attempts:
2 left
💡 Hint
The speed of light constant is given in meters per second as an integer value.
✗ Incorrect
The speed_of_light constant in scipy.constants is defined as an integer value representing meters per second. Using round on an integer returns a float, so the output is 299792458.0.
❓ data_output
intermediate1:30remaining
Number of constants in a dictionary
How many physical constants are included in the dictionary returned by
scipy.constants.physical_constants?SciPy
from scipy.constants import physical_constants print(len(physical_constants))
Attempts:
2 left
💡 Hint
Count the keys in the dictionary of physical constants.
✗ Incorrect
The physical_constants dictionary in scipy.constants contains 74 entries representing various physical constants.
🧠 Conceptual
advanced2:00remaining
Understanding units in scipy.constants
Which of the following statements about the units of constants in
scipy.constants.physical_constants is correct?Attempts:
2 left
💡 Hint
Check the structure of the values in the physical_constants dictionary.
✗ Incorrect
Each entry in physical_constants is a tuple with three elements: the numerical value, the unit as a string, and the uncertainty of the value.
🔧 Debug
advanced1:30remaining
Error raised by incorrect import
What error will this code raise?
SciPy
from scipy.constants import speed_of_lightt print(speed_of_lightt)
Attempts:
2 left
💡 Hint
Check the spelling of the imported constant.
✗ Incorrect
The import statement tries to import speed_of_lightt which does not exist in scipy.constants. This causes an ImportError.
🚀 Application
expert2:00remaining
Calculate energy equivalent of 1 kg mass using scipy.constants
Using
scipy.constants, which option correctly calculates the energy equivalent (in joules) of 1 kilogram mass using Einstein's equation E=mc²?SciPy
from scipy.constants import speed_of_light mass = 1 # in kilograms energy = ??? print(energy)
Attempts:
2 left
💡 Hint
Remember the formula E = m times c squared.
✗ Incorrect
The energy equivalent is calculated by multiplying mass by the square of the speed of light: E = m * c². Option A correctly implements this.