Please use python for this problem and making sure there is proper formatting for the python code you write:   Please use Python for this question and make sure code is formatted properly.  Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The objective of the function is to determine the a Volume object that is the result of many people at a party turning the Volume up and down. More specifically: the first line of the file is a number that indicates the initial value of a Volume  The remaining lines consist of a single character followed by a space followed by a number.  The character will be one of ‘U” or ‘D’ which stand for “up” and “down” respectively.  The function will create a new Volume object and then process each line of the file by calling the appropriate method of the Volume object which changes the value of the Volume.  The function then returns the final Volume object.   Guidelines/hints: This is a standalone function, it should NOT be inside (indented within) the class. It should be listed in the module after the Volume class and without indentation. Note that the first line of the file will be treated differently than all the other lines. Probably the easiest way to do this is to 1) open the file, 2) call the .readline() method (no s!) which reads a single line, the initial value of the Volume, then 3) call the .readlines() method which reads the rest of the lines.  Item 2) will be used to set the initial Volume and 3) will be iterated over to represent turning the volume up and down some number of time. Make sure you return the final Volume   Output for this question:  ##### partyVolume #####   >>> partyVolume('party1.txt') Volume(6.35) >>> partyVolume('party2.txt') Volume(3.75) >>> partyVolume('party3.txt') Volume(0.75)   # make sure return not print   >>> partyVolume('party1.txt')==Volume(6.35) # return not print True >>> partyVolume('party2.txt')==Volume(3.75) True >>> partyVolume('party3.txt')==Volume(0.75) True   The three 'party.txt' are in the attached images:

LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
5th Edition
ISBN:9781337569798
Author:ECKERT
Publisher:ECKERT
Chapter11: Compression, System Backup, And Software Installation
Section: Chapter Questions
Problem 6DE
icon
Related questions
Question

Please use python for this problem and making sure there is proper formatting for the python code you write:

 

Please use Python for this question and make sure code is formatted properly. 

  1. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The objective of the function is to determine the a Volume object that is the result of many people at a party turning the Volume up and down. More specifically: the first line of the file is a number that indicates the initial value of a Volume  The remaining lines consist of a single character followed by a space followed by a number.  The character will be one of ‘U” or ‘D’ which stand for “up” and “down” respectively.  The function will create a new Volume object and then process each line of the file by calling the appropriate method of the Volume object which changes the value of the Volume.  The function then returns the final Volume object.   Guidelines/hints:

    • This is a standalone function, it should NOT be inside (indented within) the class. It should be listed in the module after the Volume class and without indentation.

    • Note that the first line of the file will be treated differently than all the other lines. Probably the easiest way to do this is to 1) open the file, 2) call the .readline() method (no s!) which reads a single line, the initial value of the Volume, then 3) call the .readlines() method which reads the rest of the lines.  Item 2) will be used to set the initial Volume and 3) will be iterated over to represent turning the volume up and down some number of time.

    • Make sure you return the final Volume

 

Output for this question: 

##### partyVolume #####

 

>>> partyVolume('party1.txt')

Volume(6.35)

>>> partyVolume('party2.txt')

Volume(3.75)

>>> partyVolume('party3.txt')

Volume(0.75)

 

# make sure return not print

 

>>> partyVolume('party1.txt')==Volume(6.35) # return not print

True

>>> partyVolume('party2.txt')==Volume(3.75)

True

>>> partyVolume('party3.txt')==Volume(0.75)

True

 

The three 'party.txt' are in the attached images:

 

 

 

O party1 (4).txt - Notepad
O party2 (2).txt - Notepad
File Edit
Format View Help
File Edit
Format View
Help
2.35
U 5
D 3
U 2
18.3
D 8.5
U e.e
D 2.0
D 6.0
U 8.75
D 5.5
D 2.5
D e.75
U 9.75
D 9.0
U 7.0
D 5.5
D e.e
U 3.75
U 6.0
U 1.25
D 4.5
D 2.75
D 9.5
U 6.5
D 6.25
D 2.e
U 3.75
D 1.75
U 9.0
U 1.0
D 2.75
D 3.75
U 2.75
U 5.75
D 8.25
D 2.75
U 3.75
D e.25
D 8.0
D 2.0
D 3.5
D e.0
U 8.5
U 1.0
U 8.5
U 1.e
D 6.25
U 5.0
U 5.5
D 3.25
U 6.5
U 7.25
vD 7.25
D e.0
Ln 5, Col 1
100%
Windows (CRLF)
UTF-8
Transcribed Image Text:O party1 (4).txt - Notepad O party2 (2).txt - Notepad File Edit Format View Help File Edit Format View Help 2.35 U 5 D 3 U 2 18.3 D 8.5 U e.e D 2.0 D 6.0 U 8.75 D 5.5 D 2.5 D e.75 U 9.75 D 9.0 U 7.0 D 5.5 D e.e U 3.75 U 6.0 U 1.25 D 4.5 D 2.75 D 9.5 U 6.5 D 6.25 D 2.e U 3.75 D 1.75 U 9.0 U 1.0 D 2.75 D 3.75 U 2.75 U 5.75 D 8.25 D 2.75 U 3.75 D e.25 D 8.0 D 2.0 D 3.5 D e.0 U 8.5 U 1.0 U 8.5 U 1.e D 6.25 U 5.0 U 5.5 D 3.25 U 6.5 U 7.25 vD 7.25 D e.0 Ln 5, Col 1 100% Windows (CRLF) UTF-8
party3 (2).txt - Notepad
File
Edit Format
View Help
-3.5
U 2.5
U 9.75
D 9.5
D 5.0
U 2.75
U 4.5
D 1.75
D 8.25
D 1.25
D 2.25
U 8.25
U 2.5
U 2.0
0.25
D 4.25
U 2.5
U 4.0
U 3.0
D 6.25
U 9.75
U 4.0
U 3.75
D 9.0
U 8.75
U 2.75
D 8.5
D 6.25
D 1.0
U 4.75
D 5.5
D 1.25
D 9.5
D 6.0
D 5.5
U 6.5
D 7.0
U 7.75
D 1.25
U 5.5
D 2.75
D 0.5
U 5.0
U 4.25
D 5.25
U 7.0
U 4.5
D 5.75
D e.0
U 0.0
D 4.5
Transcribed Image Text:party3 (2).txt - Notepad File Edit Format View Help -3.5 U 2.5 U 9.75 D 9.5 D 5.0 U 2.75 U 4.5 D 1.75 D 8.25 D 1.25 D 2.25 U 8.25 U 2.5 U 2.0 0.25 D 4.25 U 2.5 U 4.0 U 3.0 D 6.25 U 9.75 U 4.0 U 3.75 D 9.0 U 8.75 U 2.75 D 8.5 D 6.25 D 1.0 U 4.75 D 5.5 D 1.25 D 9.5 D 6.0 D 5.5 U 6.5 D 7.0 U 7.75 D 1.25 U 5.5 D 2.75 D 0.5 U 5.0 U 4.25 D 5.25 U 7.0 U 4.5 D 5.75 D e.0 U 0.0 D 4.5
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Types of Function
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
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L