1. Introduction to Data Wrangling with Python
Activity 1.01: Handling Lists
Solution:
These are the steps to complete this activity:
- Import the
randomlibrary:import random
- Use the
randintmethod from therandomlibrary to create100random 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:
Figure 1.20: Section of output for random_number_list
Note
The output is susceptible to change since we are generating random numbers.
- Create a
list_with_divisible_by_3list fromrandom_number_list, which will contain only numbers that are divisible by3:list_with_divisible_by_3 = [a for a in \ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ...