Wednesday, December 10, 2014

Activity 1.3.8 - While Loops

Number Guesser Code:

I always have to shrink these pictures down a lot so they don't mess with the blog's appearance

Conclusion Questions:

1.) If you change between 1 and 20 from the previous program to between 1 and 6000, how many guesses will you need to guarantee that you have the right answer? Explain.

The most efficient way to guess would be to guess the number directly in the middle of the low and high to see if that guess is too high/too low. That allows you to remove half of the numbers from what you have to guess next. For example, between 1 and 20, you would guess 10. If 10 is too high, then your next guesses would be limited to 1-9, because you're told that 10+ is too high. Then you would keep checking the new number that is halfway between the new high and low, and continue doing that until you're left with two numbers to guess from. Cutting the total number of possible answers in half each time, this method creates a logarithmic pattern - e.g. 256, 128, 64, 32, 16, 8, 4, 2, 1. So, the number of guesses you'd need has to be the lowest power of two that's greater than the number of choices. 2^13 = 8192, which is higher than 6000 and the lowest power of two that creates such a number. So, with this method, it'd only take 13 guesses to get the number!

2.) Describe the difference between a while loop and a for loop.

A for loop is often used for lists and tuples. It runs a set of instructions for each item within an array of values. A while loop is used with conditional expressions that could run for an indefinite amount of time, unlike for loops, which simply run through a list.

Monday, December 8, 2014

Activity 1.3.7 - For Loops

Hangman Code:

Click on the image to enlarge it.


Lottery Ticket Code:

Click on the image to enlarge it.


Conclusion:

1.       Sometimes code using an iterative loop can be written without a loop, simply repeating the iterated code over and over as separate lines in the program. Explain the disadvantages of developing a program this way.

This program would run slower, as there are more lines that the computer has to run through. It also clogs up the code and makes it more difficult for programmers to read. Iterative loops help keep the code concise.

2.      Name a large collection across which you might iterate.

If you were to update the grades of everyone in the high school, you would be dealing with a large amount of students - a lot of data. Using iterative loops would help to streamline the process.

3.      What is the relationship between iteration and the analysis of a large set of data?

An iteration is some set of tasks completed on a particular object, one at a time. Iterative loops can be used to analyze large sets of data, using a relatively small amount of code to iterate each bit of data.

Thursday, December 4, 2014

Activity 1.3.6 - Tuples and Lists

Dice Roller/Letter Picker Code:


Conclusion Questions:

1.       Consider a string, tuple, and list of characters.

In []: a = 'acbde'
In []: b = ('a', 'b', 'c', 'd', 'e')
In []: c = ['a', 'b', 'c', 'd', 'e']

The values of a[3], b[3], and c[3] are all the same. In what ways are a, b, and c different?

a[3] is in a string, and cannot be indexed like a list or tuple. b[3] is in a tuple, which means it's immutable - unable to be altered in any way. c[3] is in a list, which means it works like a tuple (an array of indexed values), but it can also be changed (mutable).


2.      Why do computer programming languages almost always have a variety of variable types? Why can't everything be represented with an integer?

There are many variable types because we need a way to manipulate integers and values in a way that allows us to create functions and solve problems. While the computer eventually transforms the code into integers - 1's and 0's - it is manipulated at the programming level by substituting integers with letters and other symbols, which allows us to do more complex things with it.

Tuesday, December 2, 2014

Activity 1.3.5 - Strings

Tweet Verifier Code:


Conclusion Questions:

1.       How many characters are in this sentence? Does it matter whether Python is storing the string as one byte per character or four bytes per character?

There were 41 characters in the first sentence of the question. It shsouldn't matter how the string is stored, as long as it's at least one byte, since all alphabetical characters can be stored via ASCII code within a single byte.

2.      This question asks you about something you have not learned. In fact, the question is asking about details that go beyond what you will learn in this course. However, wondering what is going on at a lower level of abstraction – and talking about it – can be a useful strategy when learning about computing.

Describe what you think occurs in memory when the following code is executed.

In []: a = 'one string'
In []: b = 'another'
In []: c = a[:3] + ' and ' + b
In []: print(c[6:10])

This code concatenates several pieces of string together and prints a section of the concatenation. "a" and "b" are stored in the memory as 'one string' and 'another', respectively. Then the memory is storing a different variable, "c", as the concatination of the first three letters in "a" ('one'), ' and ', and all of "b" ('another'). This creates the string 'one and another', which is what the memory stores "c" as. Then part of c is printed, from the 6th to 10th character, counting the former and having the first character be counted as the 0th.

This piece of code should print the string 'd an', and, after testing in Canopy, it does. Yay!

Thursday, November 20, 2014

Blown to Bits - Chapter 2 Questions


  1. Around the middle of page 23 in the reading, a story begins about the "gae-ttong-nyue", a lady involved in a webcam incident in June 2005. Analyze this reading - how has the pervasiveness of webcams and phone cameras allowed justice to be served? How could this "Big Brother" world of ours be used against us?
  2. Elaborate on the function of an RFID, and what its initials stand for. This can be found on page 25.
  3. Summarize the story about the parking garage on page 30. Is this license plate scanning system flawed, or do the benefits outweigh the mishaps?
  4. Identify a few reasons why we "gave away" our privacy, according to the reading (Hint: Look for the bold text subtitles starting at the bottom of page 36).
  5. Pages 59 and 60 depict an interesting story debating the privacy of AOL users' search queries. Respond to the questions in the middle of page 60 - what should AOL have done with this private information?

Wednesday, November 5, 2014

App Design - Alarm Clock / Timer (Mk. II)

The text shown clips in preview mode, for some reason. It works fine in the app itself.
  1. We brainstormed a bunch of things we disliked, or things that could be designed better. Many ideas were brought to the table, and we whittled down the options by weighing their ability to be made.
  2. Honestly, we did not work well as a group. There was a lack of communication that caused us to start our app very late, which ended up hurting the final design drastically.
  3. The problem was originally that there were no alarm clocks that truly guaranteed being fully awake after turning it off - this one would include many strenuous steps in order to do so. However, due to lack of time, we ended up creating a somewhat basic timer to solve a pretty simple problem - I don't like the timer app that came with my phone.
  4. The two hardest challenges, code-wise, were aligning the internal clock with what was put into the text box, and setting up a display of the time remaining (the latter is still sort of buggy).
    1. For the former, the program had to take what the user put into the text box - the timer's length in minutes - and convert it to milliseconds for the clock, once the start button was hit. There's 60,000 milliseconds in a minute. 
    2. Ironically, the code needed to display the time remaining took more effort than the code needed for the app to simply count down internally. Variables were used in order to show a countdown that would read the time remaining and convert it into a Minutes:Seconds format. It took a bit of extra programming to get the minutes to tick down one and the seconds to go from 00 to 59, and for some reason, it ended up being a bit off from the actual alarm - the alarm generally goes off when the display reads 2-5 seconds remaining. We did not have enough time to figure this out. We also added a little bit of code so that the display would read something like "2:05" instead of "2:5".
  5. With more time, we would've added several things, including but not limited to:
    • Fixing the countdown timer to accurately reach 0 when the alarm went off
    • Added different ways to turn off the alarm besides shaking the device
    • Something akin to a clock hand to show the passage of time more visually
    • The ability to pick your own alarm sound
    • Improved user interface and better design overall
    • Various other bug fixes and usability improvements (e.g. disallowing the ability to put in negative values, etc.)

Thursday, October 16, 2014

Blown to Bits Chapter 1 - Chase's Questions


  1. It is our nature as humans to expand our capabilities and advance society in ways otherwise impossible without technology. And while we were able to sustain ourselves for many centuries with little technological growth, the rush of relatively recent advancements has greatly improved the standard of living for many people, and now we are using technology to aid third-world countries, cure diseases, and do dangerous jobs that could be harmful to ourselves.
  2. Computers are capable of being much faster than the mail service. E-mails are sent over the course of a few seconds, whereas mail is generally sent over the course of a few days, or week or so. To put this in perspective, there are 604,800 seconds in a week. So, theoretically, given the best circumstances, you could send that many emails in the time it takes to deliver one letter.
  3. All new technologies can create good and harmful effects. There are many obvious pluses to this digital explosion - you can look up anything you would need to find, you can talk with people across the globe almost instantly, and you can use programs to perform tasks that the human mind simple cannot reproduce with such speed, among countless other things. However, all this information can also be a bad thing - keeping things private can be very difficult, hackers find their way into code and steal personal information, and, of course, we could reach the singularity and robots will take over the world. 
  4. (See image):

Wednesday, October 15, 2014

Blown to Bits - Chapter 1 Questions

  1. Describe what a “koan” is.
  2. Draw a graph roughly depicting what Moore’s Law looks like. (Hint: think exponential growth)
  3. Debate and weigh the good and bad aspects of technology, and whether you would describe technology overall as good, bad, or somewhere in-between.
  4. Predict how Moore’s Law may continue in the future. Will it continue on its current path, or will it eventually level out?

Tuesday, October 7, 2014

1.1.7 Scratch Game - "Scratch-Man"

SCRATCH-MAN
Created by Timothy Coon, Jr., Connor Noble, and Ché Young


 Click me!
Click the image to head to the game's page on the Scratch website!
  1.     We split up our creative responsibilities between members of the group - I worked on art and music assets, Ché worked on stage layout and programming, and Connor worked on exploring options for the ghost/dog AI. We also met up every class and discussed what to do with the game as a whole. This allowed us to go through the creative process relatively efficiently.
  2.     I believe that we worked pretty well for the most part, however, there were certain aspects of the game that were disputed as to how they would be implemented. Despite differing views, we were able to work together as a team and make overall team decisions that benefited our project.
  3.     Ché's impressive programming skills made the stage layout work very well, and his format of character movement reduced the amount of bugs drastically. Artwork was a cinch and Connor basically figured out what not to do with the dog programming.
  4.     Implementing looping music was difficult at first, and combining our separate work took a little extra time.
  5.     We would've implemented a lives system, a game over screen, and probably a bit more retouching if given more time.