Start the "Statistica Laboratorio" virtual machine (or start you PC)
Create a new folder on Desktop, name it by you surname (e.g. "Rossi")
Start Thonny (one of the lower left icons, named "Th")
Write a simple Python program, containing just two lines as print("Ciao")
and print(18, 23)
, and save it as firstprogram.py
in the created folder
Run the program
Modify as you like the program using Thonny editor, save and run again the program.
random.random()
, that can be used after executing import random
, returns a float
random value in interval [0, 1), 0 included and 1 excluded.
Thus, it is possible to assign a random value to a variable v
by executing v = random.random()
.random.random()
in a more complex expression.
Analogously, method random.randint(a, b)
, where a
and
b
are integer values (given by literals, variables, or more complex expressions) returns a random value int
in interval [a, b], including the extremes.
Any time random.random()
is called, a different (with very high probability) value is returned. Variability of the result of random.randint(..., ...)
depends upon the interval defined by parameters.
float
value in
interval [0, 100) (hint: multiply the result of random.random()
...).int
value generated in set {0, 1, 2, 3, 4, 5}.a
and b
from the keyboard and prints 4 random numbers in interval [a, b]
.Write programs to solve the following problems.
Start solving only point 1;
then add one point at a time running again the program.
There are 3 numbers larger than 0.6