1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jolli1 [7]
2 years ago
14

2. Write a standalone function partyVolume() that takes accepts one argument, a string containing the name of a file. The object

ive 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:
Computers and Technology
1 answer:
laiz [17]2 years ago
8 0

Answer:

The Python code is given below with appropriate comments

Explanation:

#required method, assuming Volume class is defined and is accessible

def partyVolume(filename):

   #opening file in read mode, assuming file exists

   file=open(filename,'r')

   #reading initial volume

   initial=float(file.readline())

   #creating a Volume object with initial volume

   v=Volume(initial)

   #looping through rest of the lines in file

   for line in file.readlines():

       #removing trailing/leading white spaces/newlines and splitting line by white

       #space to get a list of tokens

       line=line.strip().split(' ')

       #ensuring that length of resultant list is 2

       if len(line)==2:

           #reading first value as direction (U or D)

           dir=line[0].upper()

           #reading second value as float value

           value=float(line[1])

           if dir=='U':

               #turning volume up

               v.up(value)

           elif dir=='D':

               #turning volume down

               v.down(value)

   #closing file, saving changes

   file.close()

   #returning volume

   return v

You might be interested in
WILL GIVE BRAINLIEST!!!!!!!
pishuonlain [190]

Answer:

False

Explanation:

Central Louisiana Regional Port is the small river port (not in a top 100 ports), while New Orleans Port is  $100 million a year reveniew huge port, 7th busiest in US.

3 0
2 years ago
Identify the parts used in an electric circuit- Tiles
Svetlanka [38]
<span>
battery = </span>a source of energy<span>
buzzer = </span>electric energy into sound energy<span>
motor = </span>a device used to transfer electric energy into motion<span>
off switch = </span><span>a device used to break the flow of current</span><span>
</span>
3 0
2 years ago
Read 2 more answers
If you want to open an application that does not have a tile pinned to the start menu
guapka [62]
Search for it in the start menu. Once you find it, right click and press "Pin to taskbar."
6 0
3 years ago
Which of the following mountain ranges stretches from Alabama to Canada?
Vikki [24]
The Appalachian Mountains
4 0
2 years ago
Jessie will make and sell the trending Baked California Maki. Her Peso mark up is 5.00. Selling price PHP 15.000. How much will
Levart [38]

Answer:

50%

Explanation:

The markup is the difference between the selling price and the cost price. If the mark up is greater than zero, it means there is a profit, if the markup is less than 0, it means there is a loss and if the markup is equal to 0, it means there is breakeven.

Percentage markup = (markup/cost price) * 100%

Selling price - cost price = markup

15 - cost price = 5

cost price = 10

Percentage markup = (markup/cost price) * 100% = (5/10) * 100% = 50%

7 0
2 years ago
Other questions:
  • Which is not an example of a boolean operator?
    6·2 answers
  • Write a function chat accepts a pointer to a C-string as its argument. The function should count the number of vowels appearing
    5·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    10·1 answer
  • How to buy free big money computers that earn free money everydays?
    15·1 answer
  • The natural language convention used to represent ip addresses is called the:
    15·1 answer
  • Describe an energy problem a city in 2050 will face
    6·1 answer
  • Do you know the energy unit question?
    10·1 answer
  • How do i delete cookies on a chromebook?
    8·1 answer
  • When Alice turned on her laptop this morning, the screen displayed only colorful horizontal lines. Which of the following is mos
    15·1 answer
  • How can structure of a table change in sql. What general types of changes are possible
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!