Book
Module 3 - Section 2 - Lists
Module 3 - Section 2 - Lists
Completion requirements
View
After the completion of this module the students will be able to:
- identify the various data types
- recognize lists
- create lists
- use the list methods
- use the random function
3.2.6 - Random extended
Also there is a way to pick a random item out of a list. Copy the following code to Thonny and save it as rock_paper_scissors.py :
All of the prior code generates integer numbers. If a floating point number is desired, a programmer should use the random method.
The code below generates a random number from 0 to 1
import random
my_number = random.random()
and the following code creates a random number between 10 and 45
import random
my_number = random.random() * 35 + 10
Can you create a code that generates a random number between 27 and 42?