- Write a program that identifies every number between two limits that is divisible by 7.
**[ Solution ]** - Write a program to convert Celsium ⇔ Fahrenheit. Try different method for passing data to the script:
- Prompting input on the shell.
- Accepting arguments passed during script calling.
- Reading data from a file.

**[ Solution ]** - Calculate and print the Fibonacci series: F0 = 1, F1 = 1, Fn = Fn−1 + Fn−2
**[ Solution ]** - Write a proram which determines whether a given year is a leap year or not.
- A year is a leap year, if it divisible by 4 unless
- it is divisible by 100. In this case it is not a leap year, unless
- it is divisible by 400.

**[ Solution ]** - Define yourself a list containing several elements (different value!). Find an elegant way of deleting a specific element from the list. Tip: index().
**[ Solution ]**

**List Comprehensions**- Many programming language know the concept of stacks. Python has its own equivalent (Queue), but write your own version of a stack. It should emit exeptions, if it’s empty or full.
**[ Solution ]** - In yesterday’s exercise 4 we determined whether a year was a leap year. Try to accomplish the same task using list comprehensions.
**[ Solution ]** - When working with large data, e.g. larger than 10000 elements, one should consider a less memory consuming alternative: Generator Expressions. Try to solve the last exercise using generator expressions.
**[ Solution ]**

- Many programming language know the concept of stacks. Python has its own equivalent (Queue), but write your own version of a stack. It should emit exeptions, if it’s empty or full.
**Hamster**– Write a script containing a hamster and a board object. The hamster shall move in a pattern and avoid obstacles on the board. Finally the board should have means to display the hamster’s motion.**[ Solution ] [ Video ]****Polynome**– Define a class for polynomials. One shall be able to define, derive, integrate and do math with polynomials. Do not use tools from the module numpy.**[ Solution ]****Rational numbers**– Design a class for rational numbers allowing the four arithmetics. This class shall also be able to return the reduced fraction or a float.**Remember**:- A fraction can be fully reduced by dividing numerator and dominator by the greatest common divisor.
- Rational numbers are presentated as a fraction p/q, where p ∈ Z and q ∈ N\0.

**[ Solution ]**

**Threading**– Write a threaded script for retrieving (or generating), processing (e.g. apply a function) and saving values. But do not forget:- Instead of starting a thrad for each value, one can assign threads to tasks and pass values to them using queues.
- Some operations, e.g. I/O, are not "thread-safe". Make sure nothing can go wrong.
- It can be annoying, if one tries to stop a threaded program, but it continues to run. Make sure the user can abort the program at any point.

**[ Solution]****Calculator**– Write a calculator GUI using Tk. The user shall be able to choose a function name (RadioButtons?) and enter a value, which shall be passed to the function, in a separate window (TopLevel?). The shall be closed, if the value is OK, and the result shall be displayed in the initial window.**[ Solution ]**- Write a simple Tic-Tac-Toe game using Tk. But do not forget to save important data, e.g. which field has been hit by which player!
**[ Solution ]** - Write a script for managing a phone book. Write a GUI for managing entries and export/import to/from a file or database.
**[ Solution ]** **Racetrack**– Write a threaded script for simulating a horse race. Horses shall be independently moved forward and the progress shall be displayed in a GUI, where also the winner shall be announced.**[ Solution ]**

**Arrays**– Getting used to- Create a 3 × 3-array with arbitrary values not equal 0 and resize it to a 9 × 6 array.
- Assign a m × n-slice (m, n != 0, 1, m != n) of the array to a variable.
- Set all elements of the slice equal 3/2 pi.
- Define an array with length 100 for each property:
- Distance between elements is logarithmic.
- The array is empty.

- Resize your 9 × 6 array to a 4 × 13 array and to a 1-dim. array.
- We have seen select and piecewise. What is the difference between them and where?

**[ Solution ]****Matrices**- Convert one of your 2-dim. arrays into a matrix.
- Create another matrix (same shape) using MatLab syntax.
- Perform addition and multiplication with those matrices. Convert matrices to arrays and repeat.
- Solve the linear matrix equation:

**[ Solution ]****Polynomials**- Write a script for determining the roots and extrema – both x- and y- values – of a polynomial. Use e.g. this polynomial:

f(x) = 1/3*x**5 − 2*x**2 − 6pi*x − 10**[ Solution ]** - Write a script for reading (x, y)-pairs from a file and fitting with a polynomial p. Determine the followin integral:

Highlight the integration limits using a patch.**[ Solution ]**

- Write a script for determining the roots and extrema – both x- and y- values – of a polynomial. Use e.g. this polynomial:
- Add to your script from exercise 3.2 error bars.
**[ Solution ]** **Integral and Differential**- Write your own functions for integrating and deriving 1-dimensional arrays. Compare your results with the results of the SciPy tools.
- Expand your previous script such it can derive 2-dimensional arrays:
**[***optional***]**Expand your script to interactively adjust the integration limits.

**[ Solution ]****Fourier Transformation**- Write a script for expanding fourier series to fit a given function/array.
- Expand the script to display a "Fourier spectrum".
**Remember**: A Fourier series looks like this:

**[ Solution ]**An alternative (more complex, but short) solution involving a time axis and a Fourier transformation.**3D Plotting**

- Plot 3D Lissajous figures.
**Optional**: Animate them using Mayavi's*animate*decorator. - Calculate the electrostatic potential due to a series of point charges in three dimensional space and plot equipotential surfaces.
- Calculate the time-averaged power distribution of dipoles and quadrupoles. Plot them using contour of volume plots.

- Plot 3D Lissajous figures.