Skip to content

Exercises

Exercise 1

Save your code in your Python folder and call it exercise1.

Write a program using widgets to create a login page to an application.

challenge1

Exercise 2

Save your code in your Python folder and call it exercise2.

Write a program that creates two buttons: Hello and Exit.

  • When you click on the Hello button, it should write "Hello" below the buttons.

  • When you click on the Exit button, it should close the window.

exercise2

Help

To close a window using a button in Tkinter, you can assign window.destroy to the command attribute of the button (window being the variable name of your window).

Exercise 3

Save your code in your Python folder and call it exercise3.

Write a program that creates a window with 3 entries and a button. It should then show the appropriate message when you click on the button:

exercise3

Exercise 4

Save your code in your Python folder and call it exercise4.

Using widgets, dynamically create 10 buttons, each having a number from 0 to 9:

exercise4

Help

To have the numbers horizontally aligned, you need to use the side parameter when you pack each button and specify that you want it to the left: button.pack(side=tkinter.LEFT)

Exercise 5

Save your code in your Python folder and call it exercise5.

Create a skype like "Voice over IP" (VoIP) program that reads a list of people's names and adds them to the window with a Call button:

exercise5

Exercise 6

Save your code in your Python folder and call it exercise6.

Let's improve exercise 1 and write a program checking if the username and password provided are correct. The correct username is your firstname and the correct password is 5555.

  • If the username and password are correct, it should show the message correct in green.
  • If the username and/or password are incorrect, it should show the message incorrect in red.

Exercise 7

Save your code in your Python folder and call it exercise7.

Write a program that simulates rolling a dice. It should have a button with the text Roll and when the user clicks the button, it should show a random number between 1 and 6.

exercise2

Exercise 8

Save your code in your Python folder and call it exercise8.

Write a program converting a Farenheit temperature in a Celsius temperature.

exercise8

Exercise 9

Save your code in your Python folder and call it exercise9.

Build a number guessing game