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
Friday, April 28, 2017
No Time to Use
Unfortunately this weeks post will a bit like Peoria's and 10k's, in which I pretty much didn't have the time to come up with any new developments in my journey to learn python. I have commitments and a few other class projects I need to address, so 20-time had to be put on the back burner a little bit. Rest assured, there will be new content next week.
One of the big problems of working on this 20-time project is ironically a matter of time. While I do have about 20% of class time to dedicate to my project, it only equates to a measly 48 minutes a week, which is minuscule compared to the hours I normally need to dedicate to this project in order to properly learn important concepts and ultimately write about them. This process spans over at least 2 days, usually Thursday and Friday due to commitments and work that occupies most of the week, with a required weekly blog post published by 12:00 PM on Fridays. This means that when I would post new content, the subject matter is very new to not only you, but myself. I would rather post when I felt that my content was correct and error-free, but that's completely out of my hands. This is the reason why Peoria, 10k, and this post exists.
Anyway's, in some of my spare time, I did manage to mess around with how I learn python by using a site called codecademy, a free website that can teach you how to program in multiple languages, including python. For the most part, codecademy is a good way to rapidly learn python, coupling an interactive hands on experience with dedicated literature to the subject, rather than the hard way of learning through a book, which is what I have been doing. Learning through the book is time consuming and can really only be done through dedicated sessions, as I have to be tied to a computer that can run IDLE, but learning through an online source allows for me to learn anywhere as long as I have a WiFi connection and a device with a usable keyboard. I do have some concerns with it though, especially with learning at a fast pace, which I've learned in the past isn't always a good idea, especially with a topic like programming. You need to understand everything your taking in, as they will become very relevant once you begin to use those skills. I've also had problems with some of the lessons being a bit cryptic, but with some tinkering and exploring their forums, you can eventually get through it. All in all, codecademy is great for reviewing or learning new things. Here is a link if you want to take a look for yourself.
This week didn't bring much to the table. I've so far enjoyed writing this blog, to the point that I may continue doing it towards or after the end of 20-time, so there is a possibility I may talk about different topics and avoid these types of useless posts in future. See you guys next week.
One of the big problems of working on this 20-time project is ironically a matter of time. While I do have about 20% of class time to dedicate to my project, it only equates to a measly 48 minutes a week, which is minuscule compared to the hours I normally need to dedicate to this project in order to properly learn important concepts and ultimately write about them. This process spans over at least 2 days, usually Thursday and Friday due to commitments and work that occupies most of the week, with a required weekly blog post published by 12:00 PM on Fridays. This means that when I would post new content, the subject matter is very new to not only you, but myself. I would rather post when I felt that my content was correct and error-free, but that's completely out of my hands. This is the reason why Peoria, 10k, and this post exists.
Anyway's, in some of my spare time, I did manage to mess around with how I learn python by using a site called codecademy, a free website that can teach you how to program in multiple languages, including python. For the most part, codecademy is a good way to rapidly learn python, coupling an interactive hands on experience with dedicated literature to the subject, rather than the hard way of learning through a book, which is what I have been doing. Learning through the book is time consuming and can really only be done through dedicated sessions, as I have to be tied to a computer that can run IDLE, but learning through an online source allows for me to learn anywhere as long as I have a WiFi connection and a device with a usable keyboard. I do have some concerns with it though, especially with learning at a fast pace, which I've learned in the past isn't always a good idea, especially with a topic like programming. You need to understand everything your taking in, as they will become very relevant once you begin to use those skills. I've also had problems with some of the lessons being a bit cryptic, but with some tinkering and exploring their forums, you can eventually get through it. All in all, codecademy is great for reviewing or learning new things. Here is a link if you want to take a look for yourself.
This week didn't bring much to the table. I've so far enjoyed writing this blog, to the point that I may continue doing it towards or after the end of 20-time, so there is a possibility I may talk about different topics and avoid these types of useless posts in future. See you guys next week.
Friday, April 21, 2017
If Then, Else?
Last week I said that mathematical operations were the bread and butter of programming, but now, logical operators have become the jelly that's slapped onto it.
This week, as you could probably guess, I started to learn about logic operators! Logic operators are essentially the if-then or if-else statements commonly seen in the majority of programming languages, and are used to evaluate whether a set of conditions are true within a program. These are significant as it is literally used in every program imaginable, and are the basis for modern computers. They're based on the principals of Boolean Algebra, which is a version of algebra were the values of variables are treated as either the true and/or false. Now this was the jumping off point for my knowledge of Ti-Basic and Applesoft BASIC, so please note that some of this information is iffy as I've never had much experience with them.
Now in python an If-Then statement would look something like this;
potato = input("potato")
if potato == "tomato":
print("potato tomato")
In this statement, if the variable (in if then statements this variable is known as a Sentry Variable) potato is equal to the value tomato, the computer will print the argument "potato tomato". If potato doesn't equate to "tomato", the computer will ignore the statement. If we wanted to, say, have the if-then statement do something if potato isn't "tomato", we can use the else clause:
potato = input("potato")
if potato == "tomato":
print("potato tomato")
else:
print("we need a certain red vegetable")
Now if potato doesn't equate to "tomato", the computer would print "we need a certain red vegetable". If we wanted to have the computer perform actions when potato equates to other values, we can use the elif (else-if) clause:
potato = input("potato")
if potato == "tomato":
print("potato tomato")
elif potato == "tornado":
print("potato tornado")
else:
print("we need a certain red vegetable or storm-spout thing")
With elif, if potato equates to tornado, the computer will print "potato tornado". If potato doesn't exactly equate to "tomato" or "tornado", the else clause will act as a catch-all for any other values.
If-then statements are great for user input for specific variables, like passwords. The only problem is if we mess up by entering "tamato" rather than "tomato", we can't re-input any new values for potato. The solution is to put the program into a loop, in this case a while loop. A while loop is essentially an if-then/else/else-if statement with if replaced by while, causing the program to enter a loop until certain conditions are met. If we wanted a program that will loop until "tomato" is entered by adding the while loop, it would look exactly like this:
potato = " "
while potato != "tomato":
potato = input("we need a certain red vegetable")
print("potato tomato")
The program will now loop until potato is tomato. If potato doesn't equal to tomato, the program will ask the user to enter a different value until tomato is specified. A problem with while loops can occur when the program has a slight flaw in it:
potato = " "
while potato != "tomato":
potato = print("we need a certain red vegetable")
print("potato tomato")
Output:
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
Did you see the problem? In this case, I accidentally typed a print function rather than a input function, inadvertently causing an infinite loop, printing "we need a certain red vegetable" over and over forever until we manually end it.
We can change how the condition of the sentry variable by using different comparison operators. These are the equal to (=), not equal to (≠), greater than (>), less than (<), greater than or equal to (⋝), and finally the less than or equal to (⋜) symbols that everyone fussed over in elementary school, except they are now are expressed as ==, !=, >, <, >=, <= in python respectively.
Among the logic operators, I also learned about how to generate random numbers using the random module (modules, by the way, is essentially code represented by a certain word). By using this module, we gain the randint() and randrange() functions. The randint() function produces random numbers that are between two specified values (so randint(5,10) would produce a number between 5 and 10), while the randrange() function will produce integers from a specified group of numbers, similar to randint(), but will generate any number between the specified number and 1 (so randrange(12) would generate any number between 1 and 12).
The odd thing about modules though, unlike functions, is that they need to be imported in order to be used. They aren't present by default, so they have to be loaded in using an import statement. The functions in modules also need to be called by using Dot notation, which is a fancy way of saying that you need to type the module's name and the functions name with a period in between.
*Updated. Included more information on logic operators, random integer generators and modules. Also fixed grammatical errors.
bibliography:
Python Programming for the absolute beginner, Third Edition by Michael Dawson
This week, as you could probably guess, I started to learn about logic operators! Logic operators are essentially the if-then or if-else statements commonly seen in the majority of programming languages, and are used to evaluate whether a set of conditions are true within a program. These are significant as it is literally used in every program imaginable, and are the basis for modern computers. They're based on the principals of Boolean Algebra, which is a version of algebra were the values of variables are treated as either the true and/or false. Now this was the jumping off point for my knowledge of Ti-Basic and Applesoft BASIC, so please note that some of this information is iffy as I've never had much experience with them.
Now in python an If-Then statement would look something like this;
potato = input("potato")
if potato == "tomato":
print("potato tomato")
In this statement, if the variable (in if then statements this variable is known as a Sentry Variable) potato is equal to the value tomato, the computer will print the argument "potato tomato". If potato doesn't equate to "tomato", the computer will ignore the statement. If we wanted to, say, have the if-then statement do something if potato isn't "tomato", we can use the else clause:
potato = input("potato")
if potato == "tomato":
print("potato tomato")
else:
print("we need a certain red vegetable")
Now if potato doesn't equate to "tomato", the computer would print "we need a certain red vegetable". If we wanted to have the computer perform actions when potato equates to other values, we can use the elif (else-if) clause:
potato = input("potato")
if potato == "tomato":
print("potato tomato")
elif potato == "tornado":
print("potato tornado")
else:
print("we need a certain red vegetable or storm-spout thing")
With elif, if potato equates to tornado, the computer will print "potato tornado". If potato doesn't exactly equate to "tomato" or "tornado", the else clause will act as a catch-all for any other values.
If-then statements are great for user input for specific variables, like passwords. The only problem is if we mess up by entering "tamato" rather than "tomato", we can't re-input any new values for potato. The solution is to put the program into a loop, in this case a while loop. A while loop is essentially an if-then/else/else-if statement with if replaced by while, causing the program to enter a loop until certain conditions are met. If we wanted a program that will loop until "tomato" is entered by adding the while loop, it would look exactly like this:
potato = " "
while potato != "tomato":
potato = input("we need a certain red vegetable")
print("potato tomato")
The program will now loop until potato is tomato. If potato doesn't equal to tomato, the program will ask the user to enter a different value until tomato is specified. A problem with while loops can occur when the program has a slight flaw in it:
potato = " "
while potato != "tomato":
potato = print("we need a certain red vegetable")
print("potato tomato")
Output:
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
we need a certain red vegetable
Did you see the problem? In this case, I accidentally typed a print function rather than a input function, inadvertently causing an infinite loop, printing "we need a certain red vegetable" over and over forever until we manually end it.
We can change how the condition of the sentry variable by using different comparison operators. These are the equal to (=), not equal to (≠), greater than (>), less than (<), greater than or equal to (⋝), and finally the less than or equal to (⋜) symbols that everyone fussed over in elementary school, except they are now are expressed as ==, !=, >, <, >=, <= in python respectively.
Among the logic operators, I also learned about how to generate random numbers using the random module (modules, by the way, is essentially code represented by a certain word). By using this module, we gain the randint() and randrange() functions. The randint() function produces random numbers that are between two specified values (so randint(5,10) would produce a number between 5 and 10), while the randrange() function will produce integers from a specified group of numbers, similar to randint(), but will generate any number between the specified number and 1 (so randrange(12) would generate any number between 1 and 12).
The odd thing about modules though, unlike functions, is that they need to be imported in order to be used. They aren't present by default, so they have to be loaded in using an import statement. The functions in modules also need to be called by using Dot notation, which is a fancy way of saying that you need to type the module's name and the functions name with a period in between.
*Updated. Included more information on logic operators, random integer generators and modules. Also fixed grammatical errors.
bibliography:
Python Programming for the absolute beginner, Third Edition by Michael Dawson
Friday, April 14, 2017
Back in Business with Math and Variables!
For the first time in 3 weeks, I'm typing in Python again! Currently, I've finished chapter 2 of my programming book, which dealt with types, variables, and simple i/o and now I will be going on to chapter 3, which from the title teaches about "Branching, While Loops, and Program Planning". But so far from what I've learned from the past week, is the bread and butter of programming: Mathematics. Specifically how to program simple mathematical equations, such as the x+y=z variety. From my experience of learning Ti-BASIC and Applesoft, this is the point when programming begins to be useful and applicable, as we essentially recreate that tiny calculator that you get in first grade.
First of all we have the "+", "-", "/","//","%", and "*" operators to play around with. Writing an equation using these new operators in python is similar to writing it down and solving it on paper, but now the computer does all the thinking for you. For example, you can type in 5+5 and the computer will calculate the equation and determine that the answer is 10. The only problem is that the computer doesn't tell you the answer; you have to tell it to tell you the answer after it's solved it. This means that you have to use a print function, like you would in BASIC. So, what you end up typing in Print(5+5) and then the computer will give you the answer.
An interesting thing about Python is that there are now Augmented Assignment Operators, which shorten down simple mathematical equations by attaching the "=" sign to the end of an operator . For example, x = x +5 becomes x+=5. This can help shorten and simplify larger equations that may make use of something else I've learned: variables! A variable by the way is a way to label and access information, and these things make programming a lot easier. By assigning a name for a specific value or a series of strings, you can use less space and run your program more efficiently. So if our program from above used variables, it would look something like this:
answer = 5 + 5
print(answer)
Another thing I learned, is that there are 2 different types of math in python and programming in general: integer and floating point. Integers are whole numbers, which do not have a fractional part (numbers like 1, 27, 61, -100, 0, etc), while floating point numbers are numbers with a decimal point (numbers like 2.375, -99.1, 1.0, etc). Both are used for different purposes. Integer is used when we want a nicely rounded answer (the "//" operator is specifically used for this purpose), while floating point is used for accurate "true" answers. We can also convert existing values into Integers, floating points, or simple strings using the "float()", "Int()", and "Str()" functions respectively.
Here's a program that demonstrates everything I've learned so far:
# Challenge Program "Tipper"
# Demonstrates key programming concepts
# Calculates the necessary amount of a purchase for a 15% and 20% Tip
# Nathan Czaja, 4/14/2017
bill = int(input("what is your Bills total?"))
tip15 = bill*0.15
tip20 = bill*0.20
billtip15 = int(bill+tip15)
billtip20 = int(bill+tip20)
print("\a", "Total entered: $", bill, \
"\n15% Tip: $", tip15, \
"\nBill + 15% Tip: $", billtip15, \
"\n\n20% Tip: $", tip20, \
"\nBill + 20% Tip: $", billtip20)
input("\nPress enter to exit")
These new tools are extremely helpful in STEM (Science Technology Engineering and Mathematics) applications, where equations run rampant and constant calculation becomes tiresome. Using Ohms Law (V = I *R) and the quadratic formula ( (-b+/-√(b^2 (4)ac))/2a) over and over agian can be repetitive and strenuous, so being able to use a machine to do the dirty work for you is a godsend, and is one of the reasons why computers came into being in the first place.
First of all we have the "+", "-", "/","//","%", and "*" operators to play around with. Writing an equation using these new operators in python is similar to writing it down and solving it on paper, but now the computer does all the thinking for you. For example, you can type in 5+5 and the computer will calculate the equation and determine that the answer is 10. The only problem is that the computer doesn't tell you the answer; you have to tell it to tell you the answer after it's solved it. This means that you have to use a print function, like you would in BASIC. So, what you end up typing in Print(5+5) and then the computer will give you the answer.
An interesting thing about Python is that there are now Augmented Assignment Operators, which shorten down simple mathematical equations by attaching the "=" sign to the end of an operator . For example, x = x +5 becomes x+=5. This can help shorten and simplify larger equations that may make use of something else I've learned: variables! A variable by the way is a way to label and access information, and these things make programming a lot easier. By assigning a name for a specific value or a series of strings, you can use less space and run your program more efficiently. So if our program from above used variables, it would look something like this:
answer = 5 + 5
print(answer)
Another thing I learned, is that there are 2 different types of math in python and programming in general: integer and floating point. Integers are whole numbers, which do not have a fractional part (numbers like 1, 27, 61, -100, 0, etc), while floating point numbers are numbers with a decimal point (numbers like 2.375, -99.1, 1.0, etc). Both are used for different purposes. Integer is used when we want a nicely rounded answer (the "//" operator is specifically used for this purpose), while floating point is used for accurate "true" answers. We can also convert existing values into Integers, floating points, or simple strings using the "float()", "Int()", and "Str()" functions respectively.
Here's a program that demonstrates everything I've learned so far:
# Challenge Program "Tipper"
# Demonstrates key programming concepts
# Calculates the necessary amount of a purchase for a 15% and 20% Tip
# Nathan Czaja, 4/14/2017
bill = int(input("what is your Bills total?"))
tip15 = bill*0.15
tip20 = bill*0.20
billtip15 = int(bill+tip15)
billtip20 = int(bill+tip20)
print("\a", "Total entered: $", bill, \
"\n15% Tip: $", tip15, \
"\nBill + 15% Tip: $", billtip15, \
"\n\n20% Tip: $", tip20, \
"\nBill + 20% Tip: $", billtip20)
input("\nPress enter to exit")
What this program does is calculate the amount of money needed for a 15% or a 20% tip. The operation of this program is pretty simple. For example, for variable bill, I can enter $200 dollars. The "int()" function turns the value entered into a usable integer, rather than a string that does nothing. Next, it gets multiplied with 15% and 20% to calculate the relative tips. The tips are then added to the price of the bill, to give a total owed. Finally, the next print() function displays the information calculated to the user.
The running program would look something like this:
what is your Bills total?200
Total entered: $ 200
15% Tip: $ 30.0
Bill + 15% Tip: $ 230
20% Tip: $ 40.0
Bill + 20% Tip: $ 240
Press enter to exit
>>>
These new tools are extremely helpful in STEM (Science Technology Engineering and Mathematics) applications, where equations run rampant and constant calculation becomes tiresome. Using Ohms Law (V = I *R) and the quadratic formula ( (-b+/-√(b^2 (4)ac))/2a) over and over agian can be repetitive and strenuous, so being able to use a machine to do the dirty work for you is a godsend, and is one of the reasons why computers came into being in the first place.
Friday, April 7, 2017
An Excuse for 10K
Hello. Normally this would have been about what I've learned about python, but this isn't the case. Since my last post from 2 weeks ago, I have been too busy to really learn anything about python. And this week is a special case. Like my first ever blog post, my 20-time project has been interrupted by a robotics competition, only this time it's on home turf.
The Minnesota 10,000 Lakes Regional, or as it is informally called by everyone as "10k", started on Thursday and at the time of this blog post, is currently ongoing. However for me, it's been going on since Monday night. For 2 days straight, I worked with my robotics team to get our robot up, running, and packed up for 10k. I also helped out on Wednesday night, which sucked up most of my time in the first half of the week. But then came Thursday, the opening day. In order to make up most of our teams time, we rushed out at 7:00 in the morning to get to our pits at Minnesota State University, where 10k was hosted. We began to work on our robot immediately, putting together and testing it in practice matches for nearly 14 hours straight. And then today, Friday, we began to compete in the qualification matches. Now is the time our hard work meant something. I mostly helped with general fabrication, but today I temporarily became part of our drive team, being the guy setting out gears for our robotic to pick up. It was pretty fun! Much better than scouting out matches, which involved logging in every movement of every robot on the field.
Tonight, team 3184 Blaze Robotics has so far managed to get to 15th place, with the possibility of going to quarterfinals tomorrow. I am exhausted from working so much, so I apologize for not having a on topic blog post. I also apologize for the bad grammar, but it's 11:30 and I need to get this done. Next Friday though, I promise that we'll be finally on topic.
*4/21/17 fixed grammatical errors
The Minnesota 10,000 Lakes Regional, or as it is informally called by everyone as "10k", started on Thursday and at the time of this blog post, is currently ongoing. However for me, it's been going on since Monday night. For 2 days straight, I worked with my robotics team to get our robot up, running, and packed up for 10k. I also helped out on Wednesday night, which sucked up most of my time in the first half of the week. But then came Thursday, the opening day. In order to make up most of our teams time, we rushed out at 7:00 in the morning to get to our pits at Minnesota State University, where 10k was hosted. We began to work on our robot immediately, putting together and testing it in practice matches for nearly 14 hours straight. And then today, Friday, we began to compete in the qualification matches. Now is the time our hard work meant something. I mostly helped with general fabrication, but today I temporarily became part of our drive team, being the guy setting out gears for our robotic to pick up. It was pretty fun! Much better than scouting out matches, which involved logging in every movement of every robot on the field.
Tonight, team 3184 Blaze Robotics has so far managed to get to 15th place, with the possibility of going to quarterfinals tomorrow. I am exhausted from working so much, so I apologize for not having a on topic blog post. I also apologize for the bad grammar, but it's 11:30 and I need to get this done. Next Friday though, I promise that we'll be finally on topic.
*4/21/17 fixed grammatical errors
Friday, March 24, 2017
Print("Hello World")
This week, I've finally started to learn Python! Learning the Python programming language has been always something I wanted to do, but I never got around to actually do it. I've tried before, getting halfway through the first chapter of my python programming book until I started to move into a new house. In between my move and when I started this 20-time project, I experimented with programming Ti-BASIC on my Ti-84 plus. Soon after the move, I got my Apple //e, a 33 year old vintage computer, which I began to learn how to program in it's native built-in language, Applesoft BASIC (a variant of Microsoft BASIC), and I managed to create part of a Brickout/Pong clone. And now I'm here learning to program in Python on modern machines.
At first glance, Python looks a lot like BASIC. It has similar operators, (functions that act like miniature programs) like print, or input, and appears to have a familiar syntax when viewed from a distance. And this makes sense; Python was created in the early 90's, when BASIC still reigned supreme among beginner programming languages. But Python is way more different than BASIC. For example, here's the common "Hello World" program written in Ti-BASIC, Applesoft BASIC, and Python:
Ti-BASIC: Applesoft BASIC: Python:
:Disp "Hello World" 10 PRINT "HELLO WORLD" print("Hello World")
Notice the difference between Ti-BASIC, Applesoft BASIC, and Python. Applesoft and Ti-BASIC are essentially the same except for a few slight differences (mostly the Ti-84's use of the equivalent to the print command, "Disp", and Applesoft's program line numbering system (the "10")). Python also appears to be the same, but don't let looks deceive you; it isn't. First of all, Python's operators need to be in lowercase in order to work, unlike the BASIC variants. Ti-BASIC's operators are their own characters, so you do not even need to spell them out, and operators entered into Applesoft will automatically be converted to uppercase. Python also needs it's arguments (the values needed for the operators to function) in some statements to be surrounded by parenthesis's, while Basic only needs quotations.
It might seem that Python is a bit more complicated and obtuse compared to BASIC, but Python is a powerful modern programming language. Just look at the degree of modification that Python's print function allows. By inserting special escape sequences (special characters that can perform different tasks) you can easily make big changes in how a print statement is executed. For example, placing /n in a statement creates a new line prior to the following string of text. BASIC would require a blank print statement to do the exact same thing.
For a more comprehensive comparison, here's the "Silly Strings" program from my programming book written in Python (Ignore the excessive use of the + operator. This program was originally made to demonstrate that operator and the ability to repeat a statement):
Python:
#Silly Strings
#Demonstrates string concatenation and repetition
print("You can concatenate two" + " strings with the '+' operator.")
#Concatenation Demonstration
print("\nThis string " + "may not " + "seem terr" + "ibly impressive."\
+ " But what"+ "you don't know" + " is that\n" + "it's one real" \
+ "l" + "y" + " long string, created from the concatenation " \
+"of " + "twenty-two\n" + "different strings, broken across " \
+ "six lines." + " Now are you" + " impressed? " + " " + "Okay,\n" \
+ "this " + "one " + "long" + " string is now over!")
#RIP Fingers. This keyboard sucks.
#Statement Repeat Demonstration
print("\nIf you really like a string, you can repeat it. For example,")
print("who doesn't like pie? That's right, nobody. But if really")
print("like it, you should say it like you mean it:")
print("Pie" *10)
input("Press enter to exit")
It may seem that the python version is a lot longer and cryptic than BASIC, but it is anything but that. Notice the / escape sequence in the concatenation demonstration. Python allows you to continue an entire string (a series of text) of a single statement on multiple lines. Applesoft doesn't have the ability to do that, so you have to either make multiple print statements or put it all into one single long print statement, and hope that don't reach the max character limit imposed by software bugs. It also cannot create new lines mid-argument, which would again need another print function. Python also allows programmers to repeat a statement multiple times on the fly by adding "*10". Meanwhile, BASIC needs 3 more lines of code for a For Next function in order to create a loop that repeats the word "Pie" 10 times. Even the Bell Character (a character that induces the computer to beep) is simpler in python. In Applesoft, you need to address a specific memory register in the computer to create the bell character in code, but Python only needs /a. Good luck trying to do this type of stuff on a Ti-84.
All in all, I'm impressed by Python. It seems to be even more powerful than and as intuitive as BASIC. The modability of it is unique and expansive, and given that it is a modern programming language, it can be used anywhere. I think I'm going to really like Python!
*Updated: Added emulator photos, fixed grammatical errors, and made some adjustments.
Apple //jse Emulator by Will Scullen
Bibliography:
Python Programming for the absolute beginner, Third Edition by Michael Dawson
Applesoft Basic Programming Reference Manual (1978) published by Apple Computer Inc.
At first glance, Python looks a lot like BASIC. It has similar operators, (functions that act like miniature programs) like print, or input, and appears to have a familiar syntax when viewed from a distance. And this makes sense; Python was created in the early 90's, when BASIC still reigned supreme among beginner programming languages. But Python is way more different than BASIC. For example, here's the common "Hello World" program written in Ti-BASIC, Applesoft BASIC, and Python:
Ti-BASIC: Applesoft BASIC: Python:
:Disp "Hello World" 10 PRINT "HELLO WORLD" print("Hello World")
Notice the difference between Ti-BASIC, Applesoft BASIC, and Python. Applesoft and Ti-BASIC are essentially the same except for a few slight differences (mostly the Ti-84's use of the equivalent to the print command, "Disp", and Applesoft's program line numbering system (the "10")). Python also appears to be the same, but don't let looks deceive you; it isn't. First of all, Python's operators need to be in lowercase in order to work, unlike the BASIC variants. Ti-BASIC's operators are their own characters, so you do not even need to spell them out, and operators entered into Applesoft will automatically be converted to uppercase. Python also needs it's arguments (the values needed for the operators to function) in some statements to be surrounded by parenthesis's, while Basic only needs quotations.
It might seem that Python is a bit more complicated and obtuse compared to BASIC, but Python is a powerful modern programming language. Just look at the degree of modification that Python's print function allows. By inserting special escape sequences (special characters that can perform different tasks) you can easily make big changes in how a print statement is executed. For example, placing /n in a statement creates a new line prior to the following string of text. BASIC would require a blank print statement to do the exact same thing.
For a more comprehensive comparison, here's the "Silly Strings" program from my programming book written in Python (Ignore the excessive use of the + operator. This program was originally made to demonstrate that operator and the ability to repeat a statement):
Python:
#Silly Strings
#Demonstrates string concatenation and repetition
print("You can concatenate two" + " strings with the '+' operator.")
#Concatenation Demonstration
print("\nThis string " + "may not " + "seem terr" + "ibly impressive."\
+ " But what"+ "you don't know" + " is that\n" + "it's one real" \
+ "l" + "y" + " long string, created from the concatenation " \
+"of " + "twenty-two\n" + "different strings, broken across " \
+ "six lines." + " Now are you" + " impressed? " + " " + "Okay,\n" \
+ "this " + "one " + "long" + " string is now over!")
#RIP Fingers. This keyboard sucks.
#Statement Repeat Demonstration
print("\nIf you really like a string, you can repeat it. For example,")
print("who doesn't like pie? That's right, nobody. But if really")
print("like it, you should say it like you mean it:")
print("Pie" *10)
input("Press enter to exit")
Running in the Windows Command Line:
And now the equivalent program in Applesoft Basic:
20 PRINT " "
30 PRINT "This string may not seem terribly impressive, but what you don't know is that it's one really long string, created from the concatenation of twenty-two different strings, broken across six lines.
40 PRINT "Now are you impressed? Okay, this one long string is over!"
50 PRINT "If you really like a string, you can repeat it. For example, who doesn't like pie? That's right, nobody. But if you really like it, you should say it like you mean it:"
60 For I=1 to 10
70 Print "Pie"
80 Next I
Running in a apple // emulator in 80 column mode:
Running in a apple // emulator in 80 column mode:
It may seem that the python version is a lot longer and cryptic than BASIC, but it is anything but that. Notice the / escape sequence in the concatenation demonstration. Python allows you to continue an entire string (a series of text) of a single statement on multiple lines. Applesoft doesn't have the ability to do that, so you have to either make multiple print statements or put it all into one single long print statement, and hope that don't reach the max character limit imposed by software bugs. It also cannot create new lines mid-argument, which would again need another print function. Python also allows programmers to repeat a statement multiple times on the fly by adding "*10". Meanwhile, BASIC needs 3 more lines of code for a For Next function in order to create a loop that repeats the word "Pie" 10 times. Even the Bell Character (a character that induces the computer to beep) is simpler in python. In Applesoft, you need to address a specific memory register in the computer to create the bell character in code, but Python only needs /a. Good luck trying to do this type of stuff on a Ti-84.
All in all, I'm impressed by Python. It seems to be even more powerful than and as intuitive as BASIC. The modability of it is unique and expansive, and given that it is a modern programming language, it can be used anywhere. I think I'm going to really like Python!
*Updated: Added emulator photos, fixed grammatical errors, and made some adjustments.
Apple //jse Emulator by Will Scullen
Bibliography:
Python Programming for the absolute beginner, Third Edition by Michael Dawson
Applesoft Basic Programming Reference Manual (1978) published by Apple Computer Inc.
Friday, March 17, 2017
A Excuse for Peoria
Hello.
Now this would have been a post about what 20-time and Python is, but I have 36 minutes until I have to post this, so I'm not going to have good grammar. I have been working for the last 2.9 days at the FIRST Robotics Competition in Peoria, Illinois for Blaze Robotics team 3184, our high school's robotics team. Tonight we are freaking out. We have somehow placed in the top 10 teams after today's qualifying matches, and can be picked to compete further if we win most of our games tomorrow. Problem is, some of our systems aren't fully functioning, but our competitors are fully functional. So we have a very slim but real chance of making it. I'm currently sitting in the lobby of the hotel, filled with a dwindling amount of Blaze Robotics members. A member from Trident robotics is talking to the drive team member right next to me, two senior mentors, another teammate, and the team captain, are lounging on the couch across from me, discussing strategy. To the front-right of me, 2 other members are definitely doing something, and the two hotel employees at the front desk are gossiping and being bothered by some guy from another team asking questions. A coffee table in front of me, covered in modified rope, intelligence papers on other teams performances in the qualifying matches, Mtn. Dew, power cords and cookies. I'm also typing on my main laptop, rather than the pathetic Chromebooks the schools providing us. I'm also very tired, and so is everyone else.
Did I get you to imagine a scene that has nothing to do with 20-time or Python? Yes?
Then welcome to the 20 time python blog.
Now this would have been a post about what 20-time and Python is, but I have 36 minutes until I have to post this, so I'm not going to have good grammar. I have been working for the last 2.9 days at the FIRST Robotics Competition in Peoria, Illinois for Blaze Robotics team 3184, our high school's robotics team. Tonight we are freaking out. We have somehow placed in the top 10 teams after today's qualifying matches, and can be picked to compete further if we win most of our games tomorrow. Problem is, some of our systems aren't fully functioning, but our competitors are fully functional. So we have a very slim but real chance of making it. I'm currently sitting in the lobby of the hotel, filled with a dwindling amount of Blaze Robotics members. A member from Trident robotics is talking to the drive team member right next to me, two senior mentors, another teammate, and the team captain, are lounging on the couch across from me, discussing strategy. To the front-right of me, 2 other members are definitely doing something, and the two hotel employees at the front desk are gossiping and being bothered by some guy from another team asking questions. A coffee table in front of me, covered in modified rope, intelligence papers on other teams performances in the qualifying matches, Mtn. Dew, power cords and cookies. I'm also typing on my main laptop, rather than the pathetic Chromebooks the schools providing us. I'm also very tired, and so is everyone else.
Did I get you to imagine a scene that has nothing to do with 20-time or Python? Yes?
Then welcome to the 20 time python blog.
Subscribe to:
Posts (Atom)