Bird
Raised Fist0
SciPydata~20 mins

Unit conversion utilities in SciPy - Practice Problems & Coding Challenges

Choose your learning style10 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.

Practice

(1/5)
1. Which scipy.constants attribute would you use to convert meters to kilometers?
easy
A. scipy.constants.milli
B. scipy.constants.kilo
C. scipy.constants.nano
D. scipy.constants.micro

Solution

  1. Step 1: Understand the unit prefixes in scipy.constants

    The attribute kilo represents 1000, which is the factor to convert meters to kilometers.
  2. Step 2: Apply the conversion factor

    To convert meters to kilometers, divide meters by scipy.constants.kilo (which equals 1000).
  3. Final Answer:

    scipy.constants.kilo -> Option B
  4. Quick Check:

    kilo = 1000 [OK]
Hint: Use 'kilo' for 1000 times conversion in length units [OK]
Common Mistakes:
  • Confusing 'milli' (0.001) with 'kilo' (1000)
  • Using 'nano' or 'micro' which are too small
  • Trying to add instead of multiply for length units
2. Which of the following is the correct syntax to convert 5000 meters to kilometers using scipy.constants?
easy
A. scipy.constants.kilo / 5000
B. 5000 * scipy.constants.kilo
C. 5000 / scipy.constants.kilo
D. 5000 + scipy.constants.kilo

Solution

  1. Step 1: Identify the correct operation for length conversion

    Since 1 kilometer = 1000 meters, to convert meters to kilometers, divide meters by 1000.
  2. Step 2: Use the correct scipy.constants attribute and operation

    scipy.constants.kilo equals 1000, so dividing 5000 by this converts meters to kilometers.
  3. Final Answer:

    5000 / scipy.constants.kilo -> Option C
  4. Quick Check:

    5000 / 1000 = 5 [OK]
Hint: Divide by 'kilo' to convert meters to kilometers [OK]
Common Mistakes:
  • Multiplying instead of dividing for length conversion
  • Adding instead of multiplying or dividing
  • Using the wrong constant or reversing division
3. What is the output of this code snippet?
from scipy.constants import kilo
meters = 2500
kilometers = meters / kilo
print(kilometers)
medium
A. 2.5
B. 0.0025
C. 2500000.0
D. 2500

Solution

  1. Step 1: Understand the value of kilo in scipy.constants

    kilo equals 1000, so dividing meters by kilo divides by 1000.
  2. Step 2: Calculate the division

    2500 / 1000 = 2.5, so the variable kilometers is 2.5.
  3. Final Answer:

    2.5 -> Option A
  4. Quick Check:

    2500 / 1000 = 2.5 [OK]
Hint: Divide meters by kilo (1000) to get kilometers [OK]
Common Mistakes:
  • Confusing multiplication with division
  • Misreading kilo as 0.001 instead of 1000
  • Printing the original meters value instead of converted
4. The following code is intended to convert 100 degrees Celsius to Kelvin using scipy.constants. What is the error?
from scipy.constants import zero_Celsius
celsius = 100
kelvin = celsius * zero_Celsius
print(kelvin)
medium
A. Incorrect variable name for Celsius
B. Using zero_Celsius instead of absolute_zero
C. Missing import for kelvin constant
D. Multiplication instead of addition for temperature conversion

Solution

  1. Step 1: Understand temperature conversion from Celsius to Kelvin

    Temperature conversion requires adding 273.15, not multiplying.
  2. Step 2: Identify the incorrect operation in the code

    The code multiplies celsius by zero_Celsius, which is wrong; it should add zero_Celsius.
  3. Final Answer:

    Multiplication instead of addition for temperature conversion -> Option D
  4. Quick Check:

    Temperature add zero_Celsius, don't multiply [OK]
Hint: Add zero_Celsius for temperature, don't multiply [OK]
Common Mistakes:
  • Multiplying temperature values instead of adding
  • Confusing zero_Celsius with absolute zero
  • Using wrong constants for temperature conversion
5. You want to convert a list of temperatures in Celsius to Kelvin using scipy.constants.zero_Celsius. Which code correctly performs this conversion?
hard
A. kelvin_temps = [temp + zero_Celsius for temp in celsius_temps]
B. kelvin_temps = [temp * zero_Celsius for temp in celsius_temps]
C. kelvin_temps = [temp - zero_Celsius for temp in celsius_temps]
D. kelvin_temps = [zero_Celsius - temp for temp in celsius_temps]

Solution

  1. Step 1: Recall how to convert Celsius to Kelvin

    Kelvin = Celsius + 273.15, so addition of zero_Celsius is needed.
  2. Step 2: Check list comprehension for correct operation

    kelvin_temps = [temp + zero_Celsius for temp in celsius_temps] adds zero_Celsius to each Celsius temperature, correctly converting to Kelvin.
  3. Final Answer:

    kelvin_temps = [temp + zero_Celsius for temp in celsius_temps] -> Option A
  4. Quick Check:

    Add zero_Celsius to each Celsius value [OK]
Hint: Add zero_Celsius inside list comprehension for batch conversion [OK]
Common Mistakes:
  • Multiplying temperatures instead of adding
  • Subtracting zero_Celsius instead of adding
  • Reversing subtraction order
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard