1. Introduction to Data Wrangling with Python
Activity 1.01: Handling Lists
Solution:
These are the steps to complete this activity:
- Import the
random
library:import random
- Use the
randint
method from therandom
library to create100
random numbers:random_number_list = [random.randint(0, 100) \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â for x in range(0, 100)]
- Print
random_number_list
:random_number_list
The sample output is as follows:
Note
The output is susceptible to change since we are generating random numbers.
- Create a
list_with_divisible_by_3
list fromrandom_number_list
, which will contain only numbers that are divisible by3
:list_with_divisible_by_3 = [a for a in \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ...