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
icon
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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Linked List Representation
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning