Skip to content

Latest commit

 

History

History
43 lines (22 loc) · 817 Bytes

File metadata and controls

43 lines (22 loc) · 817 Bytes

Unit 4 Practice

Exercise 1 - Number Lists

Create a list of 10 numbers between 1 and 10.

1.1

Print all the number in the list that are less than or equal to 5.

Output

numbers: [3, 3, 10, 5, 4, 5, 6, 5, 7, 2]

Less than five: [3, 3, 5, 4, 5, 5, 2]

1.2

Count the number of times the number 5 occurs in your list.

Output

numbers: [3, 3, 10, 5, 4, 5, 6, 5, 7, 2]

The number 5 occurs 3 times.

1.3

Change the value of each number in the list to be the square of itself. Then print the new list.

Output

numbers: [3, 3, 10, 5, 4, 5, 6, 5, 7, 2]

[9, 9, 100, 25, 16, 25, 36, 25, 49, 4]

Exercise 1 solution