-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_14.py
More file actions
29 lines (22 loc) · 887 Bytes
/
Copy pathday_14.py
File metadata and controls
29 lines (22 loc) · 887 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
28
29
# Day 14 : Flatten the List
def flat_list(theList):
return sum(theList, [])
# Also you can use numpy:
# Option 1 => return map(flatten, theList)
# Option 2 => return np.flatten(theList)
nested_list = [[2,4,5,6]]
# nested_list = [[2,4,5,6], [7,8,9,0]]
print(flat_list(nested_list))
print('-'*35)
# Extra Challenge: Teacher’s Salary
def your_salary():
teacher = input("Enter the teacher's name: ")
periods = int(input('Enter the number of periods: '))
rate = int(input('Enter the rate per period: '))
extra = periods - 100
extraPeriods = periods - extra
if periods > 100:
return f'\nTeacher: {teacher}\nPeriods: {periods}\nGross Salary: {extraPeriods * rate + (extra * 25):,}'
else:
return f'\nTeacher: {teacher}\nPeriods: {periods}\nGross Salary: {periods * rate:,}'
print(your_salary())