The goal of this assignment is to get acquainted with Python using Jupyter Notebooks.
You will be doing your work in a Jupyter notebook for this
assignment. You may choose to work on this assignment on a hosted
environment (e.g. tiger)
or on your own local installation of Jupyter and Python. You should use
Python 3.12 for your work. To use tiger, use the credentials you
received. If you work remotely, make sure to download the .ipynb file to
turn in. If you choose to work locally, Anaconda, miniforge, or uv
are recommended methods to install and manage Python. If you work
locally, you may launch Jupyter Lab either from the Navigator
application or via the command-line as jupyter lab
.
The assignment is due at 11:59pm on Monday, January 27.
You should submit the completed notebook file required for this
assignment on Blackboard. The
filename of the notebook should be a1.ipynb
.
Please make sure to follow instructions to receive full credit. Use a markdown cell to Label each part of the assignment with the number of the section you are completing. You may put the code for each part into one or more cells.
The first cell of your notebook should be a markdown cell with a line for your name and a line for your Z-ID. If you wish to add other information (the assignment name, a description of the assignment), you may do so after these two lines.
Write code that prints “Hello, Illinois” but split into two lines like the following
Hello,
Illinois
<name>
(5 pts)Write code that assigns your name (a string) to a variable, and then
outputs Hello, <name>
where <name>
comes from the variable. Thus, if you change the string assigned to the
variable, the output should change.
Write code that uses four variables: the gravitational constant
(G
), mass of first object (m1
), mass of second
object (m2
), and distance between them (r
).
Initialize G
, m1
, m2
, and
r
to \(6.67408 ×
10^{-11}\), \(5.972 × 10^{24}\)
(mass of the earth), \(7.342 ×
10^{22}\) (mass of the moon), and \(3.844 × 10^8\) (distance between earth and
the moon), respectively. Using the initialized variables, compute the
gravitational force (F
) according to the equation below.
\[
F = G\frac{m_1 m_2}{r^2}
\] Without using a print statement, output the
value of F
, .
Write efficient code that defines three variables
(a
, b
, and c
) from the equation
\(ax^2 + bx + c = 0\). Initialize these
variables to \(a=2\), \(b=-5\), \(c=3\). Then, compute x
using
the quadratic formula. \[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\] Note that there will be usually be two solutions due to the
+/-. Output both of them (when there is only one
solution, duplicating it is ok). I should be able to change the values
of a
, b
, and c
and have the
formula work. You do not need to write a function for
this, just assign the variables as part of the code. Also, while we will
not test with a=0
, free to add logic to deal with this
case.