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]
3 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]3 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
Yo, how can I bypass the securely filter on a chromebook?
OLga [1]
Open your Chromebook and press the power button for 30 seconds. This should bypass the admin block.

Proxy Websites. Probably one of the oldest methods of bypassing web filters, proxy websites enable users to anonymously connect to websites through outside servers. ...
VPNs. VPNS or Virtual Private Networks, work as a tunnel between two devices. ...
Browser Extensions. ...
Stolen Passwords. ...
Firefox from USB. ...
5 0
2 years ago
Members of the sales team use laptops to connect to the company network. While traveling, they connect their laptops to the inte
coldgirl [10]

Answer: Network access control (NAC)

Explanation:

The solution that should be used is the network access control. Network access control helps in keeping devices and users that are unauthorized out of ones private network.

In this case, since one will like to prevent the laptops from connecting to the network unless anti-virus software and the latest operating system patches are installed, then the network access control can be used. One can only give access to the device that it wants to give access to and prevent others from connecting.

3 0
2 years ago
Briefly explain specialisation?​
Jlenok [28]

Answer:

b

Explanation:

4 0
3 years ago
Queues can be represented using linear arrays and have the variable REAR that point to the position from where insertions can be
Levart [38]

Answer:

8

Explanation:

7 0
2 years ago
What are the steps for inserting an internal link?
julia-pushkina [17]

Answer:

=

Worksheet

Ctrl + Enter

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • Find a, b, and c<br> A a=4 square root of 6 b= 8 square root of 2 ; c= 4 square root of 2
    12·1 answer
  • A column letter above the grid, also called the ____, identifies each column.
    9·1 answer
  • In 4-bit sign magnitude representation, what is the binary encoding of the number -5?
    15·1 answer
  • Ways to be your best digital self?
    7·1 answer
  • Which of the following are valid variable names? Select 2 options.
    14·1 answer
  • In Java, Create a two part program. The first takes a user inputted number and lists the factors. The second, lists all the prim
    12·1 answer
  • What types of company functions are aided by ERP?
    9·1 answer
  • What is system software?
    14·1 answer
  • Describe a new career in computer science that may be created in the future
    11·1 answer
  • What feature should you enable to prevent the sidhistory attribute from being used to falsely gain administrative privileges in
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!