Given both a list x and a tuple y, write a function called sum_list_andOr_tuple that sums all the elements of both data structures and returns the sum. There is also an optional boolean argument into the function called separate which, if True, causes the function to return the sum of the list and the tuple separately (returns two values); separate is False by default. Please note that the function DOES NOT print anything - it only returns a value(s). See the sample output below: >>> my_list = [0, 9, 99] >>> my_tuple = (8, 12) >>> result = sum_list_andOr_tuple(my_list, my_tuple) >>> print(result) Output: 128 >>> result = sum_list_andOr_tuple(my_list, my_tuple, separate = True) >>> print(result) Output: 108, 20
Given both a list x and a tuple y, write a function called sum_list_andOr_tuple that sums all the elements of both data structures and returns the sum. There is also an optional boolean argument into the function called separate which, if True, causes the function to return the sum of the list and the tuple separately (returns two values); separate is False by default. Please note that the function DOES NOT print anything - it only returns a value(s). See the sample output below: >>> my_list = [0, 9, 99] >>> my_tuple = (8, 12) >>> result = sum_list_andOr_tuple(my_list, my_tuple) >>> print(result) Output: 128 >>> result = sum_list_andOr_tuple(my_list, my_tuple, separate = True) >>> print(result) Output: 108, 20
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
Related questions
Question
Given both a list x and a tuple y, write a function called sum_list_andOr_tuple that sums all the elements of both data structures and returns the sum.
There is also an optional boolean argument into the function called separate which, if True, causes the function to return the sum of the list and the tuple separately (returns two values); separate is False by default.
Please note that the function DOES NOT print anything - it only returns a value(s).
See the sample output below:
>>> my_list = [0, 9, 99]
>>> my_tuple = (8, 12)
>>> result = sum_list_andOr_tuple(my_list, my_tuple)
>>> print(result)
Output: 128
>>> result = sum_list_andOr_tuple(my_list, my_tuple, separate = True)
>>> print(result)
Output: 108, 20
>>> my_tuple = (8, 12)
>>> result = sum_list_andOr_tuple(my_list, my_tuple)
>>> print(result)
Output: 128
>>> result = sum_list_andOr_tuple(my_list, my_tuple, separate = True)
>>> print(result)
Output: 108, 20
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning