Day Three:

        2019-07-26 00:09:54.447005



Today was one of those days where I see all the first rounders of #100DaysOfCoders (check them out, ain't they wonderful people?) hanging their heads publically on Twitter. One of those days we all have where we decide to work on the smallest thing. The SMALLEST thing ever. I'm gonna work on this thing and it's going to do wonders for me. It's gonna be SO cool (I keep remembering that I can write in .md).

Yep. I had one of those days. I have these little alias' (alias's? aliasi? I dunno) on my command line that make me feel super coder and load up my workspaces (literally, I type in "loadup" and everyone is thrilled and claps their hands as Jupyter Notebook loads up onto my screen.

I wanted to make it do a new trick. Which I am sure is soooooo easy. But it wasn't going to work today. I even pivoted to something seemingly easier harder. It was actually harder.

BUT KNOW THIS.

(i wish i knew markdown in middle school)

I didn't spend the whole day learning nothing at all. No. I spent the whole day researching ways that don't work.

Process of elimination. That's all it is. Good old fashioned sleuthing.

Anyways I empathize. We all have this day. I ended up doing some cool s#!t anyway and I managed to stay aware of that fact all day.

oops..got lost looking at a stack overflow question. here's some code considering something I looked up today but this post is gonna be short. take care!

In [8]:
import requests
from bs4 import BeautifulSoup
In [9]:
# I literally had to reinstall a few things just now so that
# was weird
In [10]:
r = requests.get("https://en.wikipedia.org/wiki/Earth%27s_orbit")
In [11]:
r
Out[11]:
<Response [200]>
In [15]:
print(r.text[0:100], r.text[-100:-1])
<!DOCTYPE html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<title n(){mw.config.set({"wgBackendResponseTime":107,"wgHostname":"mw1329"});});</script>
</body>
</html>

I even found the ending and starting <html> tags.

In [23]:
parsed_html = BeautifulSoup(r.text)

in tutorials I read (for fun) people usually initialize the BeautifulSoup() object (that's what <- that is) to

soup = BeautifulSoup(blarg.text)

I have no idea why. It's like either everyone before them did that and didn't understand it themselves and then the next ones carried on the tradition or doesn't get that soup isn't that great of an analogy here.

Take your pick. But give people the benefit of the doubt.

In [25]:
str(parsed_html.p.text)
Out[25]:
"Earth orbits the Sun at an average distance of 149.60 million km (92.96 million mi),[1] and one complete orbit takes 365.256\xa0days (1 sidereal year), during which time Earth has traveled 940\xa0million km (584 million mi).[2] Earth's orbit has an eccentricity of 0.0167. Since the Sun constitutes 99.76% of the mass of the Sun–Earth system, the center of the orbit is extremely close to the center of the Sun.\n"

whoa..we travel 584 million miles in one year. Which means that..

In [26]:
total_miles = 584000000
total_days = 365
In [27]:
mile_per_day = total_miles / total_days

mile_per_day
Out[27]:
1600000.0

1,600,000. 1.6 MILLION miles in a day. I hope my next maths are correct

In [29]:
hours_in_day = 24

miles_per_hour = mile_per_day / hours_in_day
In [32]:
miles_per_hour # thereabouts
Out[32]:
66666.66666666667
In [34]:
miles_per_hour / 60 / 60
Out[34]:
18.51851851851852

18 miles in a second? How can I confirm this?

In [43]:
minutes_in_an_hour = 60
seconds_in_a_minute = 60

print(str(seconds_in_a_minute) + ' seconds in a minute multipled by '
     + str(minutes_in_an_hour) + ' minutes in an hour multiplied by ' 
      + str(hours_in_day) + ' equals ' 
      + str(seconds_in_a_minute
            *minutes_in_an_hour
            *hours_in_day)
     + ' seconds in a day')
60 seconds in a minute multipled by 60 minutes in an hour multiplied by 24 equals 86400 seconds in a day
In [39]:
# and
18.5 * 86400
Out[39]:
1598400.0

dang. 18.5 miles a second. I guess next time I'm having a slow day I'll just try to remember this.