# <ins>Lab #1: Python Basics</ins>

These exercises are meant to give you some practice with the concepts from Tutorial #1. There's a prompt or two for each section, as well as a final question that brings it all together. GLHF!

***
## Basic Arithmetic

1. Use the Pythagorean theorem, $a^2 + b^2 = c^2$, to find the hypotenuse length of a right triangle with side lengths $a = 6.1$ and $b = 5.6$.


```python
# Your answer below:

```

2. Use the distance modulus, $m_v - M_v = 5log(d/10 \text{ pc})$, to find the distance to a star with apparent magnitude $m_v = 0.5$ and absolute magnitude $M_v = -5.85$.


```python
# Your answer below:

```

***
## Comments

1. Write a single-line comment containing your Swings order.


```python
# Your answer below:

```

2. Write a multi-line comment describing your favorite astronomy fact.


```python
# Your answer below: 

```

***
## Printing

1. Print your favorite letter, number and symbol on the same line.


```python
# Your answer here:

```

***
## Data types

1. Use both string multiplication and concatenation to print 3 different animal noises


```python
# Your answer here:

```

2. Print a true statement using four comparison operators.


```python
# Your answer here:

```

***
## Variables

1. Use the quadratic equation, $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$, to find the roots of $5x^2 + 3x - 1$ by calculating the numerator and denominator separately. (**Tip:** When parintheses in a big equation get a little hard to read, breaking it up like this is a good way to make code easier to read.)


```python
# Your answer here:

```

***
## User input

1. Prompt the user for their age and calculate the percent of their life they've completed assuming they live to 80 years old.


```python
# Your answer here:

```

***
## Debugging

1. Rewrite the code below, fixing the errors and formatting with best practices.


```python
X1 = 17.4
Y1 = 15.6
X2 = 15.1
Y2 = 11.1

Dist = sqrt((X2-X1)^2-(Y2+Y1)^2))
print(Dist)
```

***

## Indexing

1. Print the 4th, 9th, and 15th letter and the letter at the 20th, 3rd, and 12th indices of the word "pneumonoultramicroscopicsilicovolcanoconiosis" by indexing.


```python
# Your answer below:

```

2. Print the strings "pneumono," "ultra," "volcano," and "coniosis" by slicing the word from part one.


```python
# Your answer below:

```

3. Add together every third number in the list [155,2,54,34,5,16,7,38,26,10] and print the result.


```python
# Your answer below

```

## Manipulating strings and lists

1. Fix the string "peea7nut. bt-tt9r" with string (or list) functions.


```python
# Your code below:

```

## `numpy` arrays

1. Use the Wien displacement law to calculate the temperatures of blackbodies with 20 peak wavelengths between 300nm and 700nm using arrays.

\begin{equation}
    \lambda_{peak}T = 0.29 \text{ cm K}
\end{equation}


```python
# Your code below:

```

***

## Practice: DMS/HMS Converter

While DMS (degrees, minutes, seconds) and HMS (hours, minutes, seconds) formats for celestial coordinates have their place (e.g. in every database ever), having them in decimal degrees is often more convenient for calculations. Write two scripts: one that allows the user to enter in a DMS coordinate and prints it in decimal degrees, and another for HMS coordinates.


```python
# Your answer here:


```

263e9354b3f05e4183b05d765284dfb11d06cd3a
ipynb
Jupyter Notebook
files/ASTR211_Lab1-1.ipynb
mvtea/mvtea.github.io
91cb2558e570bba35e2f0718c4c658cd7317bd5d
MIT
files/ASTR211_Lab1-1.ipynb
mvtea/mvtea.github.io
91cb2558e570bba35e2f0718c4c658cd7317bd5d
MIT
files/ASTR211_Lab1-1.ipynb
mvtea/mvtea.github.io
91cb2558e570bba35e2f0718c4c658cd7317bd5d
MIT
Qwen/Qwen-72B
1. YES
2. YES