<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Units and Quantities
Objectives
Use units
Create functions that accept quantities as arguments
Create new units
Basics
How do we define a Quantity and which parts does it have?
Step1:  Quantities can be converted to other units systems or factors by using to()
Step2:  We can do arithmetic operations when the quantities have the compatible units
Step3:  Quantities can also be combined, for example to measure speed
Step4:  <div style='background
Step5:  Composed units
Many units are compositions of others, for example, one could create new combinationes for ease of use
Step6:  and others are already a composition
Step7:  Sometime we get no units quantitites
Step8:  What happen if we add a number to this?
Step9:  Equivalencies
Some conversions are not done by a conversion factor as between miles and kilometers, for example converting between wavelength and frequency.
Step10:  Other built-in equivalencies are
Step11:  Printing the quantities
Step12:  Arrays
Quantities can also be applied to arrays
Step13:  Plotting quantities
To work nicely with matplotlib we need to do as follows
Step14:  Creating functions with quantities as units
We want to have functions that contain the information of the untis, and with them we can be sure that we will be always have the right result.
Step15:  <div style='background
Step16:  Create your own units
Some times we want to create our own units
Step17:  <div style='background
<ASSISTANT_TASK:>
Python Code:
from astropy import units as u
# Define a quantity length
# print it
# Type of quantity
# Type of unit
# Quantity
# value
# unit
# information
Explanation: Units and Quantities
Objectives
Use units
Create functions that accept quantities as arguments
Create new units
Basics
How do we define a Quantity and which parts does it have?
End of explanation
# Convert it to: km, lyr
Explanation: Quantities can be converted to other units systems or factors by using to()
End of explanation
# arithmetic with distances
Explanation: We can do arithmetic operations when the quantities have the compatible units:
End of explanation
# calculate a speed
# decompose it
Explanation: Quantities can also be combined, for example to measure speed
End of explanation
#1
#2
#3
Explanation: <div style='background:#B1E0A8; padding:10px 10px 10px 10px;'>
<H2> Challenges </H2>
 <ol>
 <li> Convert the speed in imperial units (miles/hour) using: <br>
 ```from astropy.units import imperial```
 </li>
 <li> Calculate whether a pint is more than half litre<br>
 <emph>You can compare quantities as comparing variables.</emph> <br>
 Something strange? Check what deffinition of <a href='https://en.wikipedia.org/wiki/Pint'>pint</a> astropy is using.
 </li>
 <li> Does units work with areas? calculate the area of a rectangle of 3 km of side and 5 meter of width. Show them in m^2 and convert them to yards^2</li>
</div>
End of explanation
# create a composite unit
# and in the imperial system
Explanation: Composed units
Many units are compositions of others, for example, one could create new combinationes for ease of use:
End of explanation
# what can be converted from s-1?
# or Jules?
# Unity of R
Explanation: and others are already a composition:
End of explanation
# no units
Explanation: Sometime we get no units quantitites
End of explanation
# arithmetic with no units
# final value of a no unit quantity
Explanation: What happen if we add a number to this?
End of explanation
# converting spectral quantities
# but doing it right
Explanation: Equivalencies
Some conversions are not done by a conversion factor as between miles and kilometers, for example converting between wavelength and frequency.
End of explanation
# finding the equivalencies
# but also using other systems
Explanation: Other built-in equivalencies are: 
 - parallax()
 - Doppler (dopplr_radio, doppler_optical, doppler_relativistic)
 - spectral flux density
 - brigthness temperature
 - temperature energy
 - and you can build your own
End of explanation
# Printing values with different formats
Explanation: Printing the quantities
End of explanation
# different ways of defining a quantity for a single value
# now with lists
# and arrays
# and its arithmetics
# angles are smart!
Explanation: Arrays
Quantities can also be applied to arrays
End of explanation
# allowing for plotting
from astropy.visualization import quantity_support
quantity_support()
# loading matplotlib
%matplotlib inline
from matplotlib import pyplot as plt
# Ploting the previous array
Explanation: Plotting quantities
To work nicely with matplotlib we need to do as follows:
End of explanation
# Create a function for the Kinetic energy
# run with and without units
Explanation: Creating functions with quantities as units
We want to have functions that contain the information of the untis, and with them we can be sure that we will be always have the right result.
End of explanation
#4
# run it for some values
# on Mars:
Explanation: <div style='background:#B1E0A8; padding:10px 10px 10px 10px;'>
<H2> Challenges </H2>
 <ol start=4>
  <li> Create a function that calculates potential energy where *g* defaults to Earth value, 
  but could be used for different planets. 
  Test it for any of the *g* values for any other 
  <a href="http://www.physicsclassroom.com/class/circles/Lesson-3/The-Value-of-g">planet</a>.
  </li>
 </ol>
</div>
End of explanation
# Create units for a laugh scale
Explanation: Create your own units
Some times we want to create our own units:
End of explanation
#5
Explanation: <div style='background:#B1E0A8; padding:10px 10px 10px 10px;'>
<H2> Challenges </H2>
 <ol start=5>
  <li> Convert the area calculated before `rectangle_area` in <a href="https://en.wikipedia.org/wiki/Hectare">Hectare</a>
  (1 hectare = 100 ares; 1 are = 100 m2).
  </li>
 </ol>
</div>
End of explanation
<END_TASK>