Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 34c0925

Browse files
Create Assignment on Tuple - Level 2.py
1 parent f99017e commit 34c0925

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /