0
0
SciPydata~20 mins

Unit conversion utilities in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Unit Conversion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of unit conversion using scipy.constants
What is the output of this code snippet that converts 10 kilometers to meters using scipy.constants?
SciPy
from scipy.constants import kilo
value_km = 10
value_m = value_km * kilo
print(value_m)
A10000.0
B10.0
C0.01
D1000.0
Attempts:
2 left
💡 Hint
Remember that 'kilo' in scipy.constants means 1000.
data_output
intermediate
2:00remaining
Convert array of temperatures from Celsius to Kelvin
Given an array of temperatures in Celsius, what is the resulting array after converting to Kelvin using numpy and scipy.constants?
SciPy
import numpy as np
from scipy.constants import zero_Celsius
celsius_temps = np.array([0, 25, 100])
kelvin_temps = celsius_temps + zero_Celsius
print(kelvin_temps)
A[-273.15 -248.15 -173.15]
B[0 25 100]
C[273 298 373]
D[273.15 298.15 373.15]
Attempts:
2 left
💡 Hint
Add 273.15 to Celsius to get Kelvin.
visualization
advanced
3:00remaining
Plotting unit conversions for length scales
Which option produces a plot showing meters converted to kilometers and centimeters correctly?
SciPy
import matplotlib.pyplot as plt
from scipy.constants import kilo, centi
lengths_m = [1, 5, 10]
lengths_km = [x / kilo for x in lengths_m]
lengths_cm = [x / centi for x in lengths_m]
plt.plot(lengths_m, lengths_km, label='km')
plt.plot(lengths_m, lengths_cm, label='cm')
plt.xlabel('Meters')
plt.ylabel('Converted Lengths')
plt.legend()
plt.show()
AScatter plot with kilometers values larger than meters values
BBar chart with meters, kilometers, and centimeters all equal values
CLine plot with meters on x-axis, kilometers and centimeters on y-axis, showing km values smaller than meters and cm values larger than meters
DLine plot with kilometers and centimeters both smaller than meters values
Attempts:
2 left
💡 Hint
Remember 1 meter = 0.001 kilometers and 100 centimeters.
🔧 Debug
advanced
2:00remaining
Identify the error in unit conversion code
What is the error in this code when converting 5 grams to kilograms using scipy.constants?
SciPy
from scipy.constants import kilo
mass_g = 5
mass_kg = mass_g * kilo
print(mass_kg)
AThe output is 5000.0, which is incorrect for grams to kilograms conversion
BNameError because 'kilo' is not imported
CTypeError because you cannot multiply int by float
DNo error, output is 0.005
Attempts:
2 left
💡 Hint
Check the meaning of 'kilo' and the units involved.
🚀 Application
expert
3:00remaining
Calculate energy in electronvolts from joules using scipy.constants
Which option correctly calculates the energy in electronvolts (eV) from 3.2e-19 joules using scipy.constants?
SciPy
from scipy.constants import electron_volt
energy_joules = 3.2e-19
energy_ev = energy_joules / electron_volt
print(energy_ev)
A1.6e-19
B2.0
C3.2e-19
D5.0
Attempts:
2 left
💡 Hint
1 electronvolt equals 1.6e-19 joules.