CS计算机代考程序代写 python CS1-FULL-FALL2021

CS1-FULL-FALL2021

Maíra Marques Samary

Libraries Usage

• Python has a very simple function that helps to create
pseudo random numbers. They can be

• Integers

• In the interval of [0,1]

• To generate pseudo random numbers we have to call a
library/file of Python that has many functions to help
us

Luckily…

• random.randint()

• This is a function that generates integer random numbers.

We can call this functions in two different ways:
random.randint(n,m) (with n, m integer, and n < m): Generates a random value in the interval [n, m [(open interval from the right - never generates the value m) Generating Integer Values • random.random() • This is a function that generates decimal numbers in the interval [0,1] • We assume that each value in the interval [0,1] is generated with equal probability ("uniform distribution") Generating float numbers What is the difference between the function random.randint()and the function random.random()? ?