This is a pair assignment. You should create a directory called assignment2 in cs120/assignments for this assignment. All code written for this assignment should be stored in that directory.
$ cd ~/cs120/assignments $ mkdir assignment2 $ cd assignment2
Gravity is one of the fundamental forces of nature. No matter what we try, we are pretty much always under the affect of gravity from some body. As a matter of fact, based on the laws of physics we are constantly under the affect of gravity from an almost uncountable number of items. For this assignment, you will compute the force of gravity between various elements.
The gravitational force between two objects can be computed using the equation:
F = G × M1 × M2 / r2
Where the gravitational constant G = 6.673 × 10-11, M1 and M2 are the masses (in kg) of the objects in question, and r is the distance (in meters) between the centers of mass of the two objects.
Write a function called compute_gravitational_force(mass1,
mass2, distance)
, which will compute this force. This
function takes 3 floating point values: the masses of the two
elements, and the distance beween the two items (in meters).
This function should return the gravitational force, labeled
appropriately.
You will also need functions to convert from kilometers to meters and from pounds to kilograms. Make sure you test these three functions thoroughly before you continue on.
The Sun has a mass of roughly 1.981 × 1030 kg. Its mass is over 300 times that of the Earth (5.97 × 1024 kg). Compute the gravitational force between the Sun and the Earth, assuming the average distance between them is 147 million km.
The Earth's orbit is not perfectly circular. The elliptical nature of the orbit causes the distance between the Earth and the Sun to vary by about 5 million km over the course of the year (about 2.5 million km in either direction). Write a new function that returns how this affects the gravitational force, by computing the gravitational force for every 1000 km increment in that range.
You can also use this equation to compute the force of gravity that is acting upon you from the Earth. Look up the radius of the Earth, and plug in your weight into the above function. If you try some various weights, you could probably find a shorter equation to compute this same value. Write a new function that simply compute the force of gravity (on earth).
My Pancreas:
My pancreas attracts every other
"Weird Al" Yankovic in Pancreas
Pancreas in the universe
With a force proportional
To the product of their masses
And inversely proportional
To the distance between them...
Who would have thought that real physics would appear in such an absurd song? It's true, your pancreas does attract every other pancreas in the universe. The typical human pancreas weighs about 80 grams. Compute the attractive force between your pancreas and a person who is 1 meter away from you.
Magnets, how do they work? One of the goals behind the "Grand Unified Theory" of Physics is to describe all four of the fundamental forces of the Standard Model using one single force equation. While it might seem like a silly thing to do, we know that the equations for the electro-magnetic forces and gravitational forces are very similar:
Write a function to also compute this force as well. Research the electro-magnetic force, and use your function to compute some well known magnetic forces.
The first computer generated movie ever produced, Toy Story, is still one of my favorites. It showed the world that talented artists could use computers to create compelling characters and tell touching stories. While the animation we can create in Python may be far from the quality of Pixar's work, its still possible to create fun animations. In this assignment you will use the graphics module as a computer amimation tool.
Create a Python program that uses the graphics module to create an animation. The animation can be anything you want, but must do the following:
Stupendous animations will receive extra credit. I will be the arbiter of whether an animation is stupendous .
Your program should include the traditional header, use appropriate variable names, and nicely label all values printed to the terminal. Submission are to be done through inquire.roanoke.edu through the Assignment 1 link. Both partners must submit through inquire!