Thursday, December 18, 2014

1.3.7 For Loops




Lottery Ticket

import random
def matches(ticket):
winners = []
result = 0
for x in ticket:
winners.append(random.randint(1,60))
z = 0
for y in winners:
if x == y:
z = 1
if z == 1:
result += 1
ticket.sort()
winners.sort()
print 'the winning numbers are ' + str(winners)
if z == 1:
return "your ticket had 1 match" 
if z == 0 or z >=2:
return "your ticket had " + str(result) + "matches"


Hangman

def hangman_display(guessed, secret):
ret = ""
for i in secret:
x = 0
for j in guessed:
if i.lower() in j.lower():
x = 1
if x == 1 or (i in " !,.?"):
ret - ret + i
else:
ret = ret + "-"

return ret

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.

 Really inefficient and lots of work.

 Name a large collection across which you might iterate.
 A area holding a huge amount of items.


What is the relationship between iteration and the analysis of a large set of data?
A iteration is tasks completed one at a time. Iterative loops analyze huge sets of data.

Thursday, December 11, 2014

1.3.6 Tuples and Lists

import random
def guess_letter():
           alphabet = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')
print random.choice(alphabet)


def roll_dice():
          a = random.randiant(1,6)
          b = random.randiant(1,6)
           print  a + b
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' uses a string to keep the letters. 'b' is a tuple that holds them. 'c' is a list to keep its values


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

There is a variety because not all variables can be used in the same situation they might have only a certain one that can be used.

Friday, December 5, 2014

1.3.5 Strings Conclusion



Code:
def how_elgible(essay):
ans = 0
if len(essay) <= 140:
if '"' in essay:
ans = ans + 1
if ',' in essay:
ans = ans + 1
if '!' in essay:
ans = ans + 1
if '?' in essay:
ans = ans + 1
print ans
else:



        print 'Too many characters.'







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 are 41 characters. No it does not matter how many bytes there are per character.

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])

It looks like it will say 'one string and another' then maybe it will print out the characters of 6 - 10.

Thursday, November 20, 2014

Chapter 2 Clown to Bits Questions





1.What's the difference between "public" and "readily accessible"?



2.How do websites know who you are?




3.What are some problems with "I Agree" documents?




4.Define an RFID and explain how it is used.




5.What are some personal computer monitoring software and explain what they do.

Saturday, November 8, 2014

Launcher


The Launcher app!




1.   1.       Reflect on the creative process you used. What was useful? Discuss your reflection with your partner and then write a reflection individually.
 We were looking at our phones and saw how useful a launcher app would be where you can open apps and use them more quickly than looking for your app.

2.      Reflect on the team dynamic. What helped the team work well together? Discuss your reflection with your partner and then write a reflection individually. I think we  worked well together but i think i could have put in a bit of more effort.

3.  What Problem was your APP attempting to solve?  How well does it?
                The problem we were trying to solve with our app idea was a quicker way to your apps. The screen has many apps that people use daily which will make it faster to open the apps and use them.

4.  Desribe the two hardest challenges you experienced when coding this app.  How did you overcome them.  Post a screen shot of these sections of code, and explain them.

This is the camera function it doesn't seem to be a lot of work to figure out but it took some research to actually find out the wording to get the camera to work.


The texting app is difficult because you have to send the text and have the messages stored in a database. We looked up how to fix this problem but haven't fixed it completely.
5.  Given more time how could you improve your game

We could have added another page and more apps which would make it even more helpful to the user. Also we would find a better way of using other apps in the program.

Wednesday, October 15, 2014

Blown to Bits Chapter 1 Answers

     a.) Identify the difference between exclusive and rivalrous bits.
Exclusive is only a few people have them and it is hard to keep.
Rivalrous is when you receive them from someone.
     b.) Based on your opinion, can a computer make mistakes, or are they perfect? Justify your answer.
In my opinion computers can't make mistakes because it's just doing what it is told to do and if there are any errors of some kind it's because of the program it is using.

     c.) Draw a Venn diagram regarding the pros and cons of having advanced technology.
Some pros of having advanced technology is that a are very fast at doing what you want them to do. If you want to look up something it can take about 5 seconds. Also it is easier for people to communicate around the world if they have someone not near by.

Some cons of having advanced technology is if you have some personal things that get leaked online, there is nothing you can do about it, it is forever on the internet.

     d.) Summarize Moore's Law and the advancement of processing power.

 Moore's law is an empirical observation of the progress of engineering and challenge engineers to continue their innovation. Processing power has advanced a bunch it used to be able to process 5 things at once now a computer can process a trillion things.

Tuesday, October 14, 2014

Blown to Bits Chapter 1 Questions

Define the term “bits” where does it occur?
Would you allow location services or providers to determine your location in case of emergency? (Justify your answer)
Justify how our modern technology impact our lives and state an example.
How would you respond, If personal pictures would appear on the internet.

Monday, October 6, 2014

Lesson 1.1.7 Scratch Game Bounceit!

                                                                         Bounceit!

The hardest thing about our game was making the ball bounce off of the paddle and walls off random directions. We eventually did overcome this task by looking at another tutorial that was similar to our game we made. We looked at the code they had for their ball when they would bounce off the paddle and edge and then bounce in a random direction. We then used their code and it made the ball bounce.

Mario and I worked well as a team as we did eventually come to the conclusion of what we wanted to make out of our game bounceit!

I liked the way our project came out. We started with our first version which wasn't smooth when we created it. Then we changed it so you would hit coins instead of squares and added a point system. We added a start menu a game over menu but we don't have a victory menu which was one of our only flaws