PROPOSED EXERCISES
|
PAGE 1 / 1
|
The for / while Statements
Proposed Exercises
1. Johnny deposited the amount of
s dollars in the bank. The interest rate is
p% per month.
What amount does Johnny have after
k months? The program will read
s,
p,
k and display the required amount.
2. A natural number is read. Can it be decomposed into squares?
Example: 13 is read. Answer:
Yes (because
32+22=13).
3. Print all prime numbers between two read natural numbers.
4. The
n digits of a natural number are read in order. Construct and display the formed number.
Example: if
6,
7,
3 are read, then
673 will be displayed.
5. A natural number
n is read. Display the number of digits it is composed of.
Example: if
1078 is read,
4 will be displayed.
Miniproject. Read a list of
real numbers from the keyboard until the digit
0 is encountered. Print "
a report"
containing: the number of elements, how many are positive, how many are negative, and the sum of the elements!
Editor - lectia10_probleme.py
|
|
USER FRIENDLY
In any field you work in, or if you are a student, your programs must
read and display information easily, with clear hints and helpful information.
Behind the scenes, in the code, is your program – the
processing! But the user needs ONLY
elegant and
intuitive inputs and outputs.
Therefore, pay attention to the information you request, how you present it, and what you communicate!