During session 13
Exercises
NB! The practical session exercises are always provided enough and to spare with an eye to fast / experienced students have tasks to solve. To this end, do not get upset if you do not get on all the problems in class. Take your time and complete the tasks at home!
1. Bar chart
Create a text file that contains 10 integers (each number on a separate line). Write a program that reads the numbers from the file and draws a bar chart based on the numbers (use tkinter and the canvas). The columns whose values are equal or greater than 50 should be in red; otherwise, the columns should be in blue. The values have to be added under the columns.
Example of the result:
2. Colors
You can find a list of color names that the tkinter module recognizes from http://wiki.tcl.tk/16166. Multiword color names are placed in curly brackets - you can ignore them. Write a program that displays as many of these colors as possibles. Use tkinter to solve the task.
An example of the output (easier):
An example of the output (harder):
If
- x and y are coordinates of the starting point,
- r is the radius,
- a is the angle of rotation (2*PI*number_of_colors),
- i is the iteration variable (from 0 to the number of colors),
then the coordinates of the second point (at the end of the line) are
- x+r*sin(i*a)
- y+r*cos(i*a)
3. Strong password detection
Write a function that uses regular expressions to make sure a password is strong. A strong password consists of at least eight characters, contains letters in both uppercase and lowercase, and at least one digit. You may need to test the password against multiple regular expressions to validate its strength.