Description Complete the script given to you which needs to determine the averages for each tuple in a given list of tuples, put the averages in a tuple, and print said tuple. The precision of the resulting tuple should be 2 decimal digits. The list of tuples are to be taken from the user. In the script, the input part is handled for you, and you must use the variable t. It is assigned the list of tuples you will work with. Assume that the user will always provide valid tuples with float values as input, like in the examples. Assume that an empty tuple will never be given as input. But an empty list can be given, in which case you should print an empty tuple. Check the examples for further clarification. Keep in mind that we will be grading your code not just based on these examples, but other cases as well, so try to write code which can handle all possible cases. Check out the code we provided and try to understand how it does what it does. Important: You should set the precision after the averaging operation is done, this is the correct way to do it. Otherwise your results may not match. Hint: You can convert tuples to lists and vice versa for easier management. Tip: Find out how to set the number of digits to print. Warning: You are not allowed to use imports, or the round() function. Examples: INPUT OUTPUT [(1,2,3).(4,5,6)) (2.0, 5.0) (1.0.)* [(1.)) [(0, 1), (5.5, -2, 6.4)] [(0, 0). (15.5, 8, 16.46), (7, 56, 4.21884, -1.4, 8.3), (12)] (0.0, 13.32, 14.82, 12.0) (0.5, 3.3)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

you should use python language

def read_list_of_tuples(param):
p = param.replace(' ', '')
lst =
[]
while( CinRand in p):
p.index('(') + 1
start_ind
%3D
end_ind
p.index(')')
tup =
p[start_ind:end_ind]
elem_list
tup.split(',')
%3D
while( in elem list):
elem_list.remove('')
for i in range(len(elem_list)):
elem_list[i] = float(elem_list[i])
lst.append (tuple(elem_list))
p[:start_ind
begin
1]
end =
p[end_ind + 1:]
p =
begin + end
return lst
str_t =
input()
t =
read_list_of_tuples(str_t)
# DO_NOT_EDIT_ANYTHING_ABOVE_THIS_LINE
A# DO NOT EDIT ANYTHING BELOW THIS LINE
Transcribed Image Text:def read_list_of_tuples(param): p = param.replace(' ', '') lst = [] while( CinRand in p): p.index('(') + 1 start_ind %3D end_ind p.index(')') tup = p[start_ind:end_ind] elem_list tup.split(',') %3D while( in elem list): elem_list.remove('') for i in range(len(elem_list)): elem_list[i] = float(elem_list[i]) lst.append (tuple(elem_list)) p[:start_ind begin 1] end = p[end_ind + 1:] p = begin + end return lst str_t = input() t = read_list_of_tuples(str_t) # DO_NOT_EDIT_ANYTHING_ABOVE_THIS_LINE A# DO NOT EDIT ANYTHING BELOW THIS LINE
Description
Complete the script given to you which needs to determine the averages for each tuple in a given list of tuples, put the averages in a tuple, and print said tuple.
The precision of the resulting tuple should be 2 decimal digits.
The list of tuples are to be taken from the user. In the script, the input part is handled for you, and you must use the variable t. It is assigned the list of tuples you will work with.
Assume that the user will always provide valid tuples with float values as input, like in the examples.
Assume that an empty tuple will never be given as input. But an empty list can be given, in which case you should print an empty tuple.
Check the examples for further clarification. Keep in mind that we will be grading your code not just based on these examples, but other cases as well, so try to write code which can handle all
possible cases.
Check out the code we provided and try to understand how it does what it does.
Important: You should set the precision after the averaging operation is done, this is the correct way to do it. Otherwise your results may not match.
Hint: You can convert tuples to lists and vice versa for easier management.
Tip: Find out how to set the number of digits to print.
Warning: You are not allowed to use imports, or the round() function.
Examples:
INPUT
OUTPUT
[(1,2,3),(4,5,6)]
(2.0, 5.0)
[(1,)]
(1.0,) *
[(0, 1), (5.5, -2, 6.4)]
[(О, 0), (15.5, 8, 16.46), (7, 56, 4.21884, -1.4, 8.3), (12)] (0.0, 13.32, 14.82, 12.0)
(0.5, 3.3)
[(1.44444444, 1.44555555)]
|(1.44,)
Transcribed Image Text:Description Complete the script given to you which needs to determine the averages for each tuple in a given list of tuples, put the averages in a tuple, and print said tuple. The precision of the resulting tuple should be 2 decimal digits. The list of tuples are to be taken from the user. In the script, the input part is handled for you, and you must use the variable t. It is assigned the list of tuples you will work with. Assume that the user will always provide valid tuples with float values as input, like in the examples. Assume that an empty tuple will never be given as input. But an empty list can be given, in which case you should print an empty tuple. Check the examples for further clarification. Keep in mind that we will be grading your code not just based on these examples, but other cases as well, so try to write code which can handle all possible cases. Check out the code we provided and try to understand how it does what it does. Important: You should set the precision after the averaging operation is done, this is the correct way to do it. Otherwise your results may not match. Hint: You can convert tuples to lists and vice versa for easier management. Tip: Find out how to set the number of digits to print. Warning: You are not allowed to use imports, or the round() function. Examples: INPUT OUTPUT [(1,2,3),(4,5,6)] (2.0, 5.0) [(1,)] (1.0,) * [(0, 1), (5.5, -2, 6.4)] [(О, 0), (15.5, 8, 16.46), (7, 56, 4.21884, -1.4, 8.3), (12)] (0.0, 13.32, 14.82, 12.0) (0.5, 3.3) [(1.44444444, 1.44555555)] |(1.44,)
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education