1
FONDAMENTI DI PROGRAMMAZIONE (L-Z)
EXERCISES ON PYTHON BASICS 2
TO BE DEVELOPED AS SCRIPTS
[Link] a program that asks the user a question ("Who is right?"). If the user answers "the wife" the program shows
"correct". Otherwise, the program shows "wrong!"
[Link] a calculator program. The program asks the user for a number (first operand), an operation (+,-,*,/), a number
(second operand). The program performs the operation and shows the result.
[Link] a program that asks the user for a number N. The program reads N numbers from input and shows their sum.
[Link] a program that shows the sum of only even numbers up to 100 (inclusive).
[Link] a program that shows the following calculations:
[Link] and show the first 100 prime numbers
[Link] and show the prime numbers between 1 and 100
EXERCISES ON PYTHON BASICS 3
SUGGESTIONS
▸ Do not look at the solution before trying and retrying.
▸ If you have no syntax errors but the program "doesn't work", use the Python tutor web
application to analyze its execution step by step and understand where the error is
([Link]
▸ Do not look at the solution before trying and retrying.
▸ If you look at the solution, understand it.
▸ To really understand it, you need to try to break it
(again, Python tutor is your ally).
▸ Do not look at the damn solution before trying and retrying.