Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Jupyter notebook ENSP-330-HW/ENSP-330-HW-02/ENSP-330-HW-02.ipynb

Project: ENSP 330
Views: 60
Kernel: Anaconda (Python 3)

Style Guide for Homeworks

There are multiple ways to earn full credit on your assignments. Along with a correct value, answers are expected to include units and to be in a reasonable notation. Reasonable notation would be an answer that does not have infinite digits (e.g. cannot equal 12389243.9343 joules, but must be written as 12.4 megajoules or 1.2e6 joules)

Calculations

Explicitly show how you calculate your numbers. To make your calculations using python make sure your units are defined in a variable name (e.g. speed_in_km, time_hour, energy_density_joule_per_kg). The computer may output a long answer full of digits that don't need to be displayed. Make your answer into a reasonable notation by explaining it in a text (markdown) cell at the bottom of your work

Showing your work

Handwritten

You may turn in handwritten equations that show your mathematical reasoning and intention. Handwritten assignments with an image of the work done uploaded onto sagemathcloud. Handwriting must be legible and include units.

Advanced/Optional

Some of you may want to use advanced options for your work. You may use these tools, but we can't provide lots of help or support on these either in this class.

Optional: Code with the pint library

  • Using the pint library is completely optional when working on assignments.

  • This allows the units to be multiplied and divided with the resulting units being carried out into the answer.

  • This is helpful yet advanced tool, to learn more check out the pint tutorial

Optional style: LaTeX

  • If you decide to use markdown/LaTeX for your calculations, do not stress about the alignment. It doesn't have to look perfect, your work and understanding is more important than how it looks.

  • This form of showing work is advanced and completely optional.

  • You can learn more in this tutorial

Question 1: Unit conversion

Please show the details of your work to answer these questions.

a) If you drive 20 miles, how many kilometers is that?

b) My car is traveling at 30 miles per hour, how many meters per second is that?

Solution 1a

a) This is a straightforward unit analysis. I looked up the unit conversion from miles to kilometers, and verified the units convert correctly by explicitly writing it out.

20 miles1.6 km1 mile=32 km20\ \textrm{miles} \cdot \frac{1.6\ \textrm{km}}{1\ \textrm{mile}} = 32\ \textrm{km}
speed_in_mile = 20. conversion = 1.605 speed_in_mile * conversion # answer is 32.1 km
32.1
# this is advanced but you should feel free to use this in your work # You still need to be able to do this with manual unit analysis from pint import UnitRegistry u = UnitRegistry() speed = 20. * u.mile speed.to(u.km) # answer is 32.9 kilometers
32.186879999999995 kilometer

Solution 1b

b)This is a more complex unit conversion because you are converting multiple dimensions simultaneously.

30milehour1.6kmmilehour3600sec1000mkm=14 meters per second\frac{30 mile}{hour} \cdot\frac{1.6km}{mile}\cdot\frac{hour}{3600 sec}\cdot\frac{1000 m}{km} = 14\ \textrm{meters per second}
Speed_mile = 30 km_conversion = 1.605 m_conversion = km_conversion * 1000 hour_to_seconds = 60 * 60 Speed_mile * m_conversion / hour_to_seconds # answer is 13.4 meters per second
13.375
# more practice using the unit registry to convert units for you # you can save the converted units into their own variables Speed = 30 * u.mile time = 1 * u.hour time_convert = time.to(u.meter) Speed_convert = Speed.to(u.meter) Speed_convert / time_convert # answer is 13.4 meters per second

Question 2: Scientific notation

Convert the following numbers to scientific notation.

Perform the following operations using scientific notation.

  1. Write out 3.5 trillion in scientific notation

  2. Write out 2.4 kJ in joules

  3. How many GW is 14 TW?

Solution 2

  1. 3.510123.5 \cdot10^{12}
  2. 2,400 joules2,400\ \textrm{joules}
  3. 14,000 GW14,000\ \textrm{GW}
# To use scientific notation while performing calculations, use the 'e' # in place of the 10^n scientific_notation = 3.1e6 scientific_notation
3100000.0

Question 3: Exponential Growth

If the energy use in a country is increasing at 3 percent per year, by what factor will it increase in 10 years?

Solution 3

  • increases 3% per year

  • x (fraction increase)

  • r (rate of increase) = 0.03

  • n (number of years) = 10

Energy=(1+r)nEnergy = (1 + r)^nEnergy=(1+0.03)10Energy = (1 + 0.03)^{10}Energy=1.3439Energy = 1.3439
initial_value = 1 rate = 0.03 time = 10 exponential_growth = initial_value * ((1 + rate)**time) exponential_growth # answer is 1.34 fraction increase in the next 10 years
1.3439163793441222

Question 4: Linear Growth

The amount of gasoline that a car uses is linearly related to the distance it travels. Write an equation for this relationship for a 2015 Honda Civic driven on the highway. If this car is driven 1000 miles, how much gasoline will it use?

Solution 4

In this problem, you can use unit analysis given a rate. Here we use the miles per gallon as a rate. You can cross multiply to make the miles cancel out and are left with gallons consumed.

  • gallons per mile = 1 gallon for every 31 miles

  • distance = 1000 miles

  • gallons per mile * distance = 32.1581

1 gallon31mile1000mile1=32.3 gallons\frac{1 \textrm{ gallon}}{31 mile} \cdot \frac{1000 mile}{1} = 32.3\ \textrm{gallons}
mpg = 31 distance = 1000 distance / mpg #answer is 32.3 gallons
32.25806451612903