# Center for Analysis and Design of Intelligent Agents

### Site Tools

public:t-vien-07-1:lab_1_materials

# Differences

This shows you the differences between two versions of the page.

public:t-vien-07-1:lab_1_materials [2008/01/09 17:06]
hannes
public:t-vien-07-1:lab_1_materials [2008/01/09 17:10] (current)
hannes
Line 26: Line 26:

===== In-Class Excercises ===== ===== In-Class Excercises =====
+

Line 125: Line 126:
print mytuple[3][0]  # Prints 7 print mytuple[3][0]  # Prints 7
</code> </code>
-  - Add the function **''fix''** to your program that takes in a single **''Item''** and forces its **''working''** value to **''True''**. Declare a list of names, called **''favorites''**, and instead of quitting after 10 failed attempts at using borrowed items, make the program fix all items possessed by those that have their name appear on the **''favorites''** list, but not the others.  Print out the names of those that got their items fixed and let the program borrow a few more items to see if it can now continue it's habit a bit longer.  \\ \\ <code python>+  - Add the function **''fix''** to your program that takes in a single **''Tool''** and forces its **''working''** value to **''True''**. Declare a list of names, called **''favorites''**, and instead of quitting after 10 failed attempts at using borrowed tools, make the program fix all tools possessed by those that have their name appear on the **''favorites''** list, but not the others.  Print out the names of those that got their tools fixed and let the program borrow a few more tools to see if it can now continue it's habit a bit longer.  \\ \\ <code python>
# HINT: Finding matches between two lists # HINT: Finding matches between two lists
listA = [1, 3, 5, 7, 9] listA = [1, 3, 5, 7, 9]
Line 133: Line 134:
print str(x)+" is common!"  # Prints "5 is common!, 9 is common!"       print str(x)+" is common!"  # Prints "5 is common!, 9 is common!"
</code> </code>
-  - Instead of using the **''favorites''**, only fix items for those that exist in the online Símaskrá (http://www.simaskra.is).  \\ \\ <code python>+  - Instead of using the **''favorites''**, only fix tools for those that exist in the online Símaskrá (http://www.simaskra.is).  \\ \\ <code python>
# HINT: Reading and parsing a source on the Internet # HINT: Reading and parsing a source on the Internet
import urllib                # Module for simple Internet sockets import urllib                # Module for simple Internet sockets