0% found this document useful (0 votes)
3 views3 pages

03e en Exercises Python Basics

The document outlines a series of exercises for practicing Python programming basics, including creating a question-answer program, a calculator, and programs for summing numbers and generating prime numbers. It emphasizes the importance of attempting solutions independently before consulting provided answers. Additionally, it suggests using the Python tutor web application for debugging and understanding code execution.

Uploaded by

s.mariani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

03e en Exercises Python Basics

The document outlines a series of exercises for practicing Python programming basics, including creating a question-answer program, a calculator, and programs for summing numbers and generating prime numbers. It emphasizes the importance of attempting solutions independently before consulting provided answers. Additionally, it suggests using the Python tutor web application for debugging and understanding code execution.

Uploaded by

s.mariani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like