반응형
Messi's Goal Total
Use variables to find the sum of the goals Messi scored in 3 competitions
Information
Messi goal scoring statistics:
Competition Goals
La Liga 43
Champions League 10
Copa del Rey 5
Task
-
Create these three variables and store the appropriate values using the table above:
-
la_liga_goals
champions_league_goals
-
copa_del_rey_goals
-
Create a fourth variable named total_goals that stores the sum of all of Messi's goals for this year.
Solution:
la_liga_goals = 43
champions_league_goals = 10
copa_del_rey_goals = 5
goals = {
"la_liga_goals": la_liga_goals,
"champions_league_goals": champions_league_goals,
"copa_del_rey_goals": copa_del_rey_goals
}
func = lambda x: sum(x.values())
total_goals = func(goals)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1108. JavaScript Array Filter (0) | 2022.11.09 |
---|---|
1107. I love you, a little , a lot, passionately ... not at all (0) | 2022.11.07 |
1105. Remove exclamation marks (0) | 2022.11.05 |
1104. Sum Mixed Array (0) | 2022.11.04 |
1103. Welcome! (0) | 2022.11.04 |