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.14 for your work. (Older versions may work, but your code will
be checked with Python 3.14.) To use tiger, use the credentials you
received. If you work remotely, make sure to download the .ipynb file to
turn in. If you work remotely, make sure to download the .ipynb file to
turn in. If you choose to work locally, miniforge, Anaconda, pixi or uv are probably the easiest ways
to install and manage Python. If you work locally, you may launch
Jupyter Lab either from the Navigator application (anaconda) or via the
command-line as jupyter-lab or
jupyter lab.
The assignment is due at 11:59pm on Friday, January 23.
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 a heading that includes 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, DeKalb” but split into two lines like the following
Hello,
DeKalb
<name> (10 pts)Write code that assigns your name (a string) to a variable
name, and then outputs
*****************
* Hello, <name> *
*****************
where <name> is replaced by the value of the
variable. Thus, if you change the string assigned to the variable, the
output should change. If name is "Eleanor",
then the output would be
******************
* Hello, Eleanor *
******************
Note that the number of stars changes based on the
number of characters in name. You can calculate the number
of characters using in name using len(name),
and you can create a string with n stars using
'*' * n (python’s repetition operator).
+)
with strings.Write code that assigns four variables: the gravitational constant
(G), mass of first object (m1), mass of second
object (m2), and distance between them (r).
Set G, m1, m2, and r
to \(6.67408 × 10^{-11}\), \(5.972 × 10^{24}\) (mass of the earth),
\(7.34767309 × 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, .
Initialize three variables (a , b, and
c) to \(a=1\), \(b=-5\), \(c=6\). Write code that, given these
variables, solves for \(x\) in the
equation \(ax^2 + bx + c = 0\). 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
+/-. Print both of them (when there is only one
solution, duplicating it is ok). I should be able to change just the
values of a, b, and c and have
the formula continue to work. You do not need to write
a function for this, just assign the variables as part of the code.
Also, we will not test with a=0 but you may choose to add
logic to deal with this case.