Online course

TRAINING 1

Let’s consider the following algorithm:
N=6
A=2
B=1
for i=0 to i=N do
B=B+A
endfor
print(’B=’)

1) Complete this array of numbers, giving the different steps of the algorithm :

2) What is the result printed by the algorithm ?

3) Change L2 by : "A=4"
What is the “ BVALUE ” printed at the end of the algorithm ?

TRAINING 2

On the day of the release of his latest album, an artist noticed that 1 000 fans connected to his Facebook page to discover his latest HIT. Over the next seven days, the number of views increased by 200 daily.

We note V the variable representing the number of views on this artist's Facebook page.

1) Complete lines 1, 2, 4 and 6 of the algorithm so that it calculates how many views were recorded on this artist's page in this period.

L1 N = ...
L2 V = …
L3 for i = 1 to i = N do
L4 ...
L5
Endfor
L6 print (...)

2) What is the result obtained at the end of the algorithm ?
Give an interpretation of the result in the context of the exercise.


TRAINING 3

A car loses 10% of its value every year. We want to know its price after 5 years, knowing that when purchased, it cost 35 000 euros.

1) Write an algorithm, using “ FORLOOP ” to do this calculation.

2) What will be the price of the car after 5 years ? .

Training 1 solutions

1) B line : 3 | 5 | 7 | 9 | 11 | 13 | 15

2) The “ BVALUE ” printed at the end of the algorithm is : 15.

3) The “ BVALUE ” printed at the end of the algorithm is with A=4 is 29.

Training 2 solutions

1) N = 7
V = 1000

for i = 1 to i = N do
V=V+200
Endfor
print (V)

2. The result given by the algorithm is : 2400.
Seven days after the release of his album, 2 400 fans came to discover his latest HIT on the artist's Facebook page.


Training 3 solutions

1) N=5
P=35000
for i=1 to i=N do
P=0.9*P
Endfor
print(P)

2) After 5 years, the price will be 20 667.15 euros.