Things I’ve Learned

Things I Have Learned while studying Lists:

  1. What a “set” is
  2. Sets are faster for membership testing than lists (Stackoverflow.com)
  3. Stackoverflow.com is an awesome resource (actually just confirmed it)
  4. The Zen of Python: I have the key.

If you want to attain the Zen of Python, comment regarding something significant that you have learned in this unit. It can be short but must be well written and thoughtful. I will then award you the key. (10 pts)

.join( )

As we were studying lists and the .join( ) method, I thought the syntax was odd. If you remember, we discussed that for a list such as,

>>> s = ['ratta', 'tata', 'tata', 'tat']

we could convert it to a string using .join( ) and a delimiter (in this case a space):

>>> ” “.join(t)

This would produce:

(“ratta tata tata tat”)

” “.join(t) looks odd to me. I thought it would should be t.join(” “). So I did some searching on the intertubes. I found my answer, not too shockingly, at stackoverflow.com.

Click the link, read the questions and responses then comment as to why you think  ” “.join(t) was selected by Python developers to convert a list into a string.

Homework: 10 pts.

Center Your Web Page

It’s has been very popular to center your web page. This may change in the future to something not thought of as yet; but, you are probably looking at this post because you want your web page centgered.

Reset the Browser Style Sheet

First, browsers set their own margins, padding, text ,etc. using their default CSS page. There is lots of information on the web regarding this. For now, let’s reset the margins and padding to “0″.

*{
     margin: 0;
     padding: 0;
}

The asterisk indicates this is a universal style and tells the browsers to set this for all elements on the page.  We reset the margin and padding in order to keep the various browsers from using their own default settings and giving us fits when trying to establish our own padding and margin. There are lots of “reset” type style sheets available on the web. You might want to check them out.

Create a Wrapper

You will need a wrapper in which all the elements of your page will reside. It is where we control the centering of your web page and its contents.

 #wrapper {
     width: 960px;
     margin: 0 auto;
 }

You determine the overall width of your web page. The margin: 0 auto: sets the top and bottom margins to 0 and the side margins to auto which centers the page.

Add an Explorer Hack

We need to add an align center to the body of your web page. This fixes a fault in some Explorer pages.

body {
     text-align:center; /*For IE6 Shenanigans*/
}

Reset Text Alignment

Since we’ve added this align center to the body tag, we need to correct it or all text on your web page will be centered unless explicity changed with CSS. So, we add the following to our #wrapper div CSS.

 

#wrapper {
     width: 960px;
     margin: 0 auto;
     text-align: left;
}

All the Code

You should end up with the following code:

*{
margin:0;
padding:0;
}

body{
text-align:center; /*For IE6 Shenanigans*
}

#wrapper{
width:960px;
margin:0 auto;
text-align:left
}

List Shortcut

When creating a list, you can skip adding all the quotes around and commas between elements of the list. Let Python do it for you by creating a string then convering it to a list using the .split() method.

>>> cheeses= “cheddar gouda swiss”.split()
>>> cheeses
['cheddar', 'gouda', 'swiss']

Get Adobe Flash player

Jon M. for his contribution

 

 

Think Python, Chapter 10, Lists: 10-1 & 10-2

Read 10-1 thru 10-2 in Think Python.

After reading, add a comment (question or question) on this post regarding a question you have after the reading and doing examples or a comment which summarizes your understanding.  Your comment must

  • Show depth of understanding
  • Can be an extension of the reading as in something you know about the subject but was not covered
  • Will be proof you have read the two sections
  • Merely quoting the text is not acceptable

Comments will account for 10% of your grade for this part of the unit.

We will do the examples in class tomorrow.

Code Wars II – Strings

Let us know how Code Wars worked for you. Tak the poll by clicking the button below.



Braves Booster Club Logo Contest

Here is your chance to design a new logo for next year’s Kamiakin merchandise. Two winners will receive a gift certificate and a t-shirt with their winning design. ONE ENTRY PER STUDENT.

Entries will not be returned and become the property of the Kamiakin Booster Club.

Finalists will be notified with final presentations being made at the Spring Sports Awards Night. Click on the link below for more information and the entry form.

 

kamiakin logo contest entry form 2012

Flash AS3 Drag and Drop Tutorials by Hannah N.


Drag and Drop Part 1: Basic Drag and Drop

 

Get Adobe Flash player

 

Drag and Drop part 2: Drag and Drop with User Feedback

 

Get Adobe Flash player

Top 10 Programming Languages to Keep You Employed

Check out this article at eWeek.com

Hard Drive Click of Death

Return top