|
| 1 | +#lex_auth_01269442027919769669 |
| 2 | + |
| 3 | +#Global variables |
| 4 | +child_id=(10,20,30,40,50) |
| 5 | +chocolates_received=[12,5,3,4,6] |
| 6 | + |
| 7 | +def calculate_total_chocolates(): |
| 8 | + #Remove pass and write your logic here to find and return the total number of chocolates |
| 9 | + return sum(chocolates_received) |
| 10 | + |
| 11 | + |
| 12 | +def reward_child(child_id_rewarded,extra_chocolates): |
| 13 | + #Remove pass and write your logic here |
| 14 | + if extra_chocolates < 1: |
| 15 | + print("Extra chocolates is less than 1") |
| 16 | + return |
| 17 | + if child_id_rewarded not in child_id: |
| 18 | + print("Child id is invalid") |
| 19 | + return |
| 20 | + chocolates_received[child_id.index(child_id_rewarded)] += extra_chocolates |
| 21 | + print(chocolates_received) |
| 22 | + |
| 23 | + |
| 24 | + # Use the below given print statements to display the output |
| 25 | + # Also, do not modify them for verification to work |
| 26 | + |
| 27 | + #print("Extra chocolates is less than 1") |
| 28 | + #print("Child id is invalid") |
| 29 | + #print(chocolates_received) |
| 30 | + |
| 31 | + |
| 32 | +print(calculate_total_chocolates()) |
| 33 | +#Test your code by passing different values for child_id_rewarded,extra_chocolates |
| 34 | +reward_child(20,2) |
0 commit comments