This is a stub meant to separate 20-time posts from newer posts.
Please Ignore.
Here is a puppy for your troubles:
Thursday, May 25, 2017
Friday, May 19, 2017
End of the Line
To be honest, I thought that last weeks blog post was the last blog post. But it turns out this blog post is the last blog post, rather than last weeks blog post which I thought was the last blog post. But now this is the last blog post. This weeks blog post, like the last few blog posts, will have nothing to do with programming python. This last week I have been preparing for presentations, rather than doing any research on new programming topics. Also I thought last weeks blog post was the last blog post...
You know how on some TV shows, writers will often try to make up filler material that consists of stuff that is done to death and horribly cliche. These are specials where the characters go to a foreign country like the UK (every long running US cartoon has done this at least once), or another state like Hawaii. There's also running the same plot over and over again with new things (think of Scooby Doo) to make it seem like each episode is new. Then there the one or two episodes that every show since the dawn of the television has done: the compilation. These are episodes that focus on the "highlights" and the "best of" what the show has to offer, and are what I can imagine to be a TV writers last ditch defense against having a script, or not having a script. So since I have no idea what to post, lets do a sort of version of that, but in a analytical way.
Statistics
*please note, for the sake of privacy of readers these numbers have been approximated. Figures come from Bloggers built in statistics.
Over all, nearly 160 people have seen this blog. Nearly 81% of them used Chrome, 7% used Safari, 6% used Firefox, 2% used SamsungBrowser, 1% used Internet Explorer, and less than 1% used something called Phantom JS. The interesting thing about this is that people still use Internet Explorer, which was effectively killed off by Microsoft in favor of the Edge browser. My guess is that these readers were using OS's like Windows XP or Windows 7, which come with Internet Explorer by default. They could also be just sticking to the man.
In speaking of OS's, Windows was used by the majority of users, at nearly 50%. Meanwhile MacOS and Linux followed at more than 15%, Unix at 13%, and common smartphone OS's comprising the rest.
The majority of this blogs readers are from the United States, while there were a couple from other countries like Germany, the UK, and even Croatia. It's pretty awesome to see that your stuff is getting read by people from another part of the globe.
The most popular post was Print("Hello World"), which compared Python to Ti-BASIC and Applesoft BASIC. That post was my first serious post, and is probably the one I'm most proud of. I was surprised by the amount of views it generated, so much so that I actually edited it and completely redid everything, since it seemed to act as the introduction to the blog. A lot of the views came from Richmond's Information Science Daily, which is run by information science practitioner Richmond Davies. I have to thank him for introducing nearly a third of the blogs readers to my work.
Behind the Scenes
For 20-time python, I used the book Python Programming for the absolute beginner by Michael Dawson and the site codecademy for research. Python Programming for the absolute beginner is good and all, but is very slow compared to codecademy, which goes at a much faster pace, at least in part due to its interactivity. I also used a version of Python 3.0 and the Idle interpreter for the actual programming. For experimentation, I used Rep>it, a free online Python interpreter, and to run the vector code I used trinket.io, a site that allows you to embed a Python interpreter on web pages.
For the Ti-BASIC, I originally learned from Ti-Basic Developer, a site dedicated to the Ti-BASIC programming language for Ti-83 and Ti-84 series of calculators. I learned Applesoft through the original Applesoft ][ BASIC Programming Reference Manual that came with the original Apple ][ plus (although I have a Apple //e). Interesting though, is that it seems to be the original Integer BASIC instead, which is slightly incompatible with the actual Applesoft Basic. For emulating the Apple //e, I used the Apple //jse online emulator by Will Scullen.
The End of The Line
To be honest, this was a fun project. Being able to write and use my own code is amazing, even though I was under intense deadlines for the past few months. The blogging about something I cared about is pretty cool, and seeing the statistics light up after every blog post was exciting. As I said in my last post, I want to continue studying python, even through college, and will continue to blog on about it, even though the projects done by next Thursday. Thank you guys for reading my haphazardly written 20-time blog. It's been a wild ride.
Thank you.
Friday, May 12, 2017
Talk'in about the future
Well, after nearly 3 months and 8 posts later, we are getting very near the end of this project. Currently, my class is transitioning to the presentation part of our 20-time unit, so the blogging will actually start dying down at this point. For many, tonight will be their last post, but since I am not one of those people, it may be a good time to start planning ahead for future of this blog.
This 20-time blog will be re-purposed into a sort-of general purpose tech blog that will take a look at technology and other cool things, like rockets and vintage computers. Of course the python programming will keep on going, but the post-a-friday thing will immediately go away. Since all I will have is time, it makes no sense to pump out rushed, haphazardly written blog posts instead of good, quality content.
This new blog will feature a new topics that aren't necessarily programming oriented. I already some rough drafts in the works that would go a great deal into stuff like vintage cassette data interfaces to the demonstration of audio generators, and the comparison of school computers of the past and present. These are still works in progress at this point, and they'll come in a little bit later.
Of course, life finds a way to make that little bit later, into what hopefully isn't a lot later. I am entering a new stage life where I will be going to a big place filled with smart people (hint: I'm going to college). I'm also wrapping up high school at this time, and which means it's crunch time for finals. So, the blog may be set aside for awhile.
If your wondering about where is all the new shiny content that I keep saying I will post, I'm sorry to disappoint you. For the last few weeks, I've been too busy to fully concentrate on 20-time, and when I do concentrate, I'm learning about content that isn't fully usable for the blog. It's been about stuff I'v already went over, or is generally ignorable. I'm sorry for the inconvenience.
Here's a snugly puppy for your troubles:
This 20-time blog will be re-purposed into a sort-of general purpose tech blog that will take a look at technology and other cool things, like rockets and vintage computers. Of course the python programming will keep on going, but the post-a-friday thing will immediately go away. Since all I will have is time, it makes no sense to pump out rushed, haphazardly written blog posts instead of good, quality content.
This new blog will feature a new topics that aren't necessarily programming oriented. I already some rough drafts in the works that would go a great deal into stuff like vintage cassette data interfaces to the demonstration of audio generators, and the comparison of school computers of the past and present. These are still works in progress at this point, and they'll come in a little bit later.
Of course, life finds a way to make that little bit later, into what hopefully isn't a lot later. I am entering a new stage life where I will be going to a big place filled with smart people (hint: I'm going to college). I'm also wrapping up high school at this time, and which means it's crunch time for finals. So, the blog may be set aside for awhile.
If your wondering about where is all the new shiny content that I keep saying I will post, I'm sorry to disappoint you. For the last few weeks, I've been too busy to fully concentrate on 20-time, and when I do concentrate, I'm learning about content that isn't fully usable for the blog. It's been about stuff I'v already went over, or is generally ignorable. I'm sorry for the inconvenience.
Here's a snugly puppy for your troubles:
Friday, May 5, 2017
Reviewing With The Vector Solver
Today I will be reviewing most of the programming concepts I've learned in the past 3 months using a program that I wrote to help me with my pre-calculus homework. This is probably the first time I've ever used python as an actual tool, which is pretty exciting! The primary function of the program is to solve vector addition/subtraction problems, but before I go on to show it off and explain how it works, I'll need to do a quick rundown of what a vector is and how to solve vector problems in general.
In physics and math, a vector is a quality that has both direction and magnitude. Direction refers to the heading of the object, which is usually represented in degrees or cardinal directions such as north, south, east, or west. The magnitude can be anything ranging from how fast the object is traveling, it's distance, or the amount of force it exerts. Examples of a vector quality would be something like an airliner flying at 230 mph while traveling 35° in relation to the equator or the force of two groups of people in a tug of war. Using this information is useful for finding out stuff like how fast a car is moving after a collision or how much force it would take a lumberjack to cut down a tree.
Vector problems deal with adding or subtracting vectors with one another, and typically look like this:
A Space Shuttle is preparing to land at Kennedy Space Center and is flying to the runway at 250 mph at an 120° angle. However, there are 35 mph wind gusts from the north that is pushing against the Shuttle. What is the Space Shuttles actual magnitude and direction?
In this problem, the Space Shuttle is coming in at a magnitude of 250 mph and a direction of 120°, while the wind is pushing it at an angle of 270° at 35 mph. The goal is to find the magnitude and direction the Shuttle is actually traveling. We can find this by separating the two vectors into two right triangles. Using the magic of SohCahToa (Sine(opposite/hypotenuse), Cosine(adjacent/hypotenuse), Tangent(opposite/adjacent)), it's possible to get the opposite(o) and adjacent(a) sides of each triangle. It would look something like this:
Triangle A (Space Shuttle):
Sin120 = (o/250)
o = 216.51 mph
Cos120= (a/250)
a = 125 mph
Triangle B (Wind):
Sin270 = (o/35)
o = -35 mph
Cos270 = (a/35)
a = 0 mph
Since the opposite and adjacent sides represent the values on the x axis and y axis respectively, we can make ordered pairs for each triangle:
Triangle A: < -125, 216.51>
Triangle B: < 0, -35 >
We can add these ordered pairs together to find the opposite and adjacent sides of the resulting vector triangle. However, before we can do this, we have to determine what part of the ordered pair is negative and positive by examining what sector the vectors angle lies on something known as the unit circle:
You can interact with this trinket by clicking on the output and the run button. It has already been started for you.
This is what I call the Vector Addition/Subtraction Magnitude and Direction Finder (or VASMaDiF). What it does is take in input from the user, essentially do all the math we used to solve the problem above, and display the answers.
It first imports the math module, as the functions we need like sine, cosine, tangent, and square root, aren't available by default. The program then asks for the angle, magnitude, and sector of each vector from the user. Since the values entered are considered strings, they have to be converted into actual numbers to be useful, in this case floating point numbers for added accuracy.
It then solves for each vectors components (remember the right triangles?) by using the math.sin() and math.cos() functions. These functions output the answer in radians, so it is necessary to convert them into degrees with the math.radians() function. The opposite and adjacent components then become absolute numbers with the abs() function, which is necessary for the next piece of code, where it is important for every variable used to be positive rather than negative.
2 sets of If-Elif-Else functions (one for each vector) then determine if the x or y axis is negative based on what sector the vector's angle lies. Some problems will have angles in sectors were they do not belong (for example: 45° South of West, which is in sector 3, so it would actually be 225°), so we can make their x and/or y axis negative as per the sector entered, giving us the correct values.
Next, the new ordered pairs are added together so we can solve for magnitude and direction. To find magnitude, we first square the opposite (Y3) and the adjacent (X3) by using the ** exponential mathematical operator followed by 2. Then they are added and square rooted with the math.sqrt() function. To find the direction, Y3 is divided by X3 and the result goes through an math.atan() (arc tangent) function. Since the answer is also in radians, we use a math.degree function to convert it into degrees (I'm uncertain why math.radians doesn't work in this case). Determining whether to add 180° is up to the user.
Finally, the program spits out the answers in print statements. This is where a new function comes into play: round(). I wanted to round the answer to the hundredths place, so I placed the variables into the round() function followed by a comma and a number that indicates to the place it's rounded to, which in this case is 2.
If we enter the values expressed in the example problem, we get this as the output:
*Answers rounded to hundredths place
Vector Component Ordered Pair:
< -125.0 , 216.51 >
< -0.0 , -35.0 >
Resulting Ordered Pair:
< -125.0 , 181.51 >
Resulting Magnitude:
220.39
Resulting Direction:
-55.45
It's pretty much the same, except for the direction not being added with 180°. This program will pretty much help with any problem involving only 2 vectors, but it can be defeated if your solving for one of the original vectors. This probably could be remedied in another version, however as the vector unit in precalc has been finished already, there currently is no point in me modifying the code.
*update: inserted code
In physics and math, a vector is a quality that has both direction and magnitude. Direction refers to the heading of the object, which is usually represented in degrees or cardinal directions such as north, south, east, or west. The magnitude can be anything ranging from how fast the object is traveling, it's distance, or the amount of force it exerts. Examples of a vector quality would be something like an airliner flying at 230 mph while traveling 35° in relation to the equator or the force of two groups of people in a tug of war. Using this information is useful for finding out stuff like how fast a car is moving after a collision or how much force it would take a lumberjack to cut down a tree.
Vector problems deal with adding or subtracting vectors with one another, and typically look like this:
A Space Shuttle is preparing to land at Kennedy Space Center and is flying to the runway at 250 mph at an 120° angle. However, there are 35 mph wind gusts from the north that is pushing against the Shuttle. What is the Space Shuttles actual magnitude and direction?
In this problem, the Space Shuttle is coming in at a magnitude of 250 mph and a direction of 120°, while the wind is pushing it at an angle of 270° at 35 mph. The goal is to find the magnitude and direction the Shuttle is actually traveling. We can find this by separating the two vectors into two right triangles. Using the magic of SohCahToa (Sine(opposite/hypotenuse), Cosine(adjacent/hypotenuse), Tangent(opposite/adjacent)), it's possible to get the opposite(o) and adjacent(a) sides of each triangle. It would look something like this:
Triangle A (Space Shuttle):
Sin120 = (o/250)
o = 216.51 mph
Cos120= (a/250)
a = 125 mph
Triangle B (Wind):
Sin270 = (o/35)
o = -35 mph
Cos270 = (a/35)
a = 0 mph
Since the opposite and adjacent sides represent the values on the x axis and y axis respectively, we can make ordered pairs for each triangle:
Triangle A: < -125, 216.51>
Triangle B: < 0, -35 >
We can add these ordered pairs together to find the opposite and adjacent sides of the resulting vector triangle. However, before we can do this, we have to determine what part of the ordered pair is negative and positive by examining what sector the vectors angle lies on something known as the unit circle:
The unit circle is just the standard grid with the x and y axis on it, but it has multiple angles jutting out from the center. The idea is that certain angles lie on the positive and negative sides of the x and/or y axis, with certain combinations being separated into specific sectors numbered 1-4 at 90° increments ordered in a counterclockwise direction. For example, in sector 2 only the y-axis is positive, while in sector 3, both axis's are negative. According to the chart, the Space Shuttle is traveling at an angle of 120°, an angle within sector 2, so the x-axis value of 125 becomes negative. The wind gusts are at angle of 270°, which is in sector 3, so both the x and y components are negative. It is only after this determination that we can proceed to add them together:
< -125, 216.51 >
+ < -0, -35 >
< -125, 181.51 >
We now have the adjacent (y) and opposite (x) components of the resultant vector, allowing for the shuttles actual magnitude to be solved. To solve for magnitude, we use the Pythagorean Theorem
(a² + b² = c² or o² + a² = h²) to solve what is essentially the hypotenuse of the resultant triangle:
-125² + 181.51² = c²
√48570.88 = √c²
c = 220.39 mph
Finally, we can solve for the direction by using arc tangent (𝜽 = tan⁻¹(a/o)):
𝜽 = tan⁻¹(-125 / 181.51)
𝜽 = -34.55°
Because the value 125 is negative, the angle has been inverted and flipped on both axis's. In order to get the proper angle, we have to add 180° to the direction, which gives us 145.45°. So the answer would be that the Space Shuttles actual heading is 220.39 mph @ 145.45°.
This can be a lot of work to do, especially when you have to do an entire packet based on these problems, which is where my program comes in:
# Vector addition/subtraction magnitude and direction finder V.0.1
# Nathan Czaja, 5/2/2017
import math
# Vector Input
First_Angle = float(input("First Angle:"))
First_Mag = float(input("First Magnitude:"))
First_Sector = float(input("First Sector:"))
Second_Angle = float(input("Second Angle:"))
Second_Mag = float(input("Second Magnitude:"))
Second_Sector = float(input("Second Sector:"))
#Find Opposite and Adjacent
#(<X1,Y1>)
Y1 = abs(First_Mag * math.sin(math.radians(First_Angle)))
X1 = abs(First_Mag * math.cos(math.radians(First_Angle)))
#(<X2,Y2>)
Y2 = abs(Second_Mag * math.sin(math.radians(Second_Angle)))
X2 = abs(Second_Mag * math.cos(math.radians(Second_Angle)))
#Define Sector (First)
if First_Sector == 4:
Y1 = Y1 * -1
elif First_Sector == 3:
Y1 = Y1 * -1
X1 = X1 * -1
elif First_Sector == 2:
X1 = X1 * -1
else:
Y1 = Y1
X1 = X1
#Define Sector (Second)
if Second_Sector == 4:
Y2 = Y2 * -1
elif Second_Sector == 3:
Y2 = Y2 * -1
X2 = X2 * -1
elif Second_Sector == 2:
X2 = X2 * -1
else:
Y2 = Y2
X2 = X2
# New Vector Order Pair (<X3,Y3>)
Y3 = Y2+Y1
X3 = X2+X1
#New Vector Magnitude
New_Mag = math.sqrt((Y3**2)+(X3**2))
#New Vector direction
New_Divide = Y3/X3
New_Angle = math.atan((New_Divide))
#Convert New_Angle to degrees
New_Angle = math.degrees(New_Angle)
print("\n*Answers rounded to hundredths place")
print("Vector Component Ordered Pair:\n"\
"<",round(X1,2),",",round(Y1,2),">\n"\
"<",round(X2,2),",",round(Y2,2),">\n")
print("Resulting Ordered Pair:\n"\
"<",round(X3,2),",",round(Y3,2),">\n")
print("Resulting Magnitude:\n",round(New_Mag,2))
print("Resulting Direction:\n",round(New_Angle,2))
This is what I call the Vector Addition/Subtraction Magnitude and Direction Finder (or VASMaDiF). What it does is take in input from the user, essentially do all the math we used to solve the problem above, and display the answers.
It first imports the math module, as the functions we need like sine, cosine, tangent, and square root, aren't available by default. The program then asks for the angle, magnitude, and sector of each vector from the user. Since the values entered are considered strings, they have to be converted into actual numbers to be useful, in this case floating point numbers for added accuracy.
It then solves for each vectors components (remember the right triangles?) by using the math.sin() and math.cos() functions. These functions output the answer in radians, so it is necessary to convert them into degrees with the math.radians() function. The opposite and adjacent components then become absolute numbers with the abs() function, which is necessary for the next piece of code, where it is important for every variable used to be positive rather than negative.
2 sets of If-Elif-Else functions (one for each vector) then determine if the x or y axis is negative based on what sector the vector's angle lies. Some problems will have angles in sectors were they do not belong (for example: 45° South of West, which is in sector 3, so it would actually be 225°), so we can make their x and/or y axis negative as per the sector entered, giving us the correct values.
Next, the new ordered pairs are added together so we can solve for magnitude and direction. To find magnitude, we first square the opposite (Y3) and the adjacent (X3) by using the ** exponential mathematical operator followed by 2. Then they are added and square rooted with the math.sqrt() function. To find the direction, Y3 is divided by X3 and the result goes through an math.atan() (arc tangent) function. Since the answer is also in radians, we use a math.degree function to convert it into degrees (I'm uncertain why math.radians doesn't work in this case). Determining whether to add 180° is up to the user.
Finally, the program spits out the answers in print statements. This is where a new function comes into play: round(). I wanted to round the answer to the hundredths place, so I placed the variables into the round() function followed by a comma and a number that indicates to the place it's rounded to, which in this case is 2.
If we enter the values expressed in the example problem, we get this as the output:
*Answers rounded to hundredths place
Vector Component Ordered Pair:
< -125.0 , 216.51 >
< -0.0 , -35.0 >
Resulting Ordered Pair:
< -125.0 , 181.51 >
Resulting Magnitude:
220.39
Resulting Direction:
-55.45
It's pretty much the same, except for the direction not being added with 180°. This program will pretty much help with any problem involving only 2 vectors, but it can be defeated if your solving for one of the original vectors. This probably could be remedied in another version, however as the vector unit in precalc has been finished already, there currently is no point in me modifying the code.
*update: inserted code
Thursday, May 4, 2017
Mini Post: An Ad for 20-Time Python; Because Why Not?
20-time python isn't the only thing I'm currently doing in my media literacy class. There is myriad of things I have to do alongside this blog, which will normally range from essays and worksheets, to projects like videos and presentations, but recently they both have collided for my advertising final. We were assigned to produce a 30 second ad to explain what our 20-time projects were all about, using persuasion techniques such as logos (an appeal to logic), ethos ( an appeal to ethics), and pathos (a appeal to emotions), along with common ad archetypes. Normally I wouldn't have even mentioned something like this, but since I *may* get some extra credit, I might as well do it.
It's kind of okay, isn't it? The voice over wasn't good quality and the camera work wasn't too nice, but it turned out much better than I expected. I was using an original iPhone 5 to film the commercial so the video and audio wasn't too nice, but it did the job. The nice thing about using the phone for filming is that it was small enough that I could place it precariously on boxes in order to get optimal viewing angles of me and the monitor screens. You can kinda see the effects this in the "check us out:" IDLE bit, where both the camera and my laptops LCD screen were shaking at the start of the scene. I made the video pan up in software, to try to hide it.
Something that surprised me during this assignment was the quality of the audio from the iPhone. It has the expected hiss that you would typically get from a phone recording but when I spoke, I sounded very soft and weaselly. I was expected it to be a little bit crisper, but that's probably what I get for using a phone instead of an actual camera.
The thing that rescues a project isn't the camera, but the video editing software. Typically other students would use a video editor like WeVideo on their phones and computers, but I opted for something much more different and archaic: Windows Movie Maker. Sure it's been unsupported by Microsoft, but it still works. Sure, it can only output videos at what probably isn't a resolution of 1080p, but I'm familiar with it. Sure, I can't dub music on top of the voice recording without exporting and reloading it, but I can make it fade in and out nice enough. I found it to be much nicer to use than having to learn the basics of WeVideo for something that needed to be done in a small amount of time. Learning how to use WeVideo probably would have been the better long term choice, but with something that took me part of the afternoon to make, It felt that it would have been a bit trivial at best.
The background music by the way, is Parallax by LEMMiNO
Subscribe to:
Posts (Atom)