-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7_assignments.py
More file actions
27 lines (16 loc) · 818 Bytes
/
7_assignments.py
File metadata and controls
27 lines (16 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Define a function that returns the contents (e.g. in m3) of a box. It takes 3 parameters: (1) Length, (2) width and (3) heigth
from handy_functions.my_functions import calculate_content, capitalize_names
# use the function
calculate_content(10, 3, 5)
# Define a function that accepts a lists, capitalizes every name in the list, and retuns this capitalized list. You can use: ['Jim', 'John', 'Marc', 'Danny', 'Peter']
my_list = ['jim', 'john', 'marc', 'danny', 'peter']
my_new_list = capitalize_names(my_list)
# normal loop to update a list
for idx, name in enumerate(my_new_list):
my_new_list[idx] = name.upper()
# list comprehension to update a list
[name.lower() for name in my_new_list]
#
numbers_list = [10, 20, 30, 40, 50]
numbers_list = [number for number in numbers_list if number < 30]
pass