DM536/DM550
Ex, Fri 23-10-15
Discuss how to model things in the “real world” by objects. In particular, discuss how to model the objects that are relevant for the second part of the fractal and the second part of the DNA project. Come up with possible class diagrams in small groups and discuss them with everyone. Try to learn about design choices by comparing the differences in them
Lab, Mon 19-10-15
You can pick up your printed assignments at this class or in my letter box afterwards. They will remain there until the next assignment is due.
Exercises:
Ex, Fri 09-10-15
We will discuss some of these exercises:
Then do:
Lab, Mon 05-10-15
For the assignment:
Place a printed version in my letter box at IMADA just outside the Vector room.
Remember, even though something doesn’t quite work in your implementation, don’t lose hope. Hand it in anyway and make sure to document what doesn’t work.
Exercises:
Lab, Mon 28-09-15
Exercises:
Ex, Fri 25-09-15
Project status
- Not started yet
- Started but stuck
- Started and progressing nicely
- Finished
Exercises:
Lab, Mon 21-09-15
Exercises:
Lab, Mon 14-09-15
Exercises:
Some solutions: 5.3, 5.4, 5.6, 7.2.
Ex, Fri 11-09-15
Exercises:
1
2
3
4
5
def print_n(s, n):
if n <= 0:
return
print s
print_n(s, n-1)
Recursion: A function that calls itself.
Fibonacci:
Nature:
Sierpinski triangle:
Koch snowflake:
Lab, Mon 07-09-15
If you haven’t already, go ahead and do the tutorial from Lab, Thu 03-09-15.
Exercises:
- 1.2-4. We already covered most of this in Lab, Thu 03-09-15.
- 2.1 and 2.2-3. (2.4 is no where to be found.)
Then, exercise from weekly note:
Write a small program that interacts with the user by e.g. asking for the user’s name, then welcoming the user etc. Use your creativity to create an interesting dialogue. Look up the functions
raw_input()
andinput()
in the library reference to handle user input
Now it gets interesting! First, install swampy. Go to the bottom of this page to find a guide.
Some solutions: 3.3.
Don’t forget that there are TurtleWorld related solutions here and here.
Lab, Thu 03-09-15
Peter wants you to take a look at the Python documentation. Note that we are using Python 2.7 and not 3.
Specifically, you should glance through:
- https://docs.python.org/2.7/reference/simple_stmts.html#the-print-statement
- https://docs.python.org/2.7/reference/expressions.html#binary-arithmetic-operations
- https://docs.python.org/2.7/reference/expressions.html#boolean-operations
and
- https://docs.python.org/2.7/library/stdtypes.html#boolean-operations-and-or-not
- https://docs.python.org/2.7/library/stdtypes.html#numeric-types-int-float-long-complex
Next, launch Python and start working on the Python tutorial.
Installing Python, pip and swampy
First, we install Python and pip
.
Windows and Mac OSX:
Go to python.org. In the menubar, hover your mouse over “Downloads” and choose “Python 2.7.10”.
Install as normally. pip
will also be installed.
Linux (Ubuntu):
Open a terminal and write
sudo apt-get install python python-pip
Next, install swampy using pip.
Windows:
Open Command Prompt by searching for cmd
in the Windows search menu. In cmd
type.
cd C:\Python27\Scripts
You are now in the correct folder to execute pip
.
All platforms:
Open a terminal/cmd if you haven’t already and write
pip install swampy
If using Linux (and possibly Mac OSX) and the above command downloads something, but then fails, try
sudo pip install swampy
You will be prompted for your password.
Useful links
- Course homepage
- Book: PDF | HTML
- Python Tutor - Visualize Python scripts as they run
- Trinket - Play around with Turtle World directly in the browser