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
Please help me idk I suck at this stuff ​
kap26 [50]
I would say the best clear answer is D, because A is a little bit unclear but I would say the best answer is D.

Why?

Mesh Topology is expensive considering more links as compared to Ring topology.


4 0
2 years ago
What is the likely long-term consequence of an increase in the relative percent of greenhouse gases in Earth’s atmosphere?
NemiM [27]

Answer:

Earth's average temperature will increase.

Explanation:

5 0
3 years ago
Write a program to calculate surface area and volume of a sphere (ball). The program will ask user to input radius (meter(s)) of
oee [108]

Answer:

The following program is to calculate the surface area and volume of a sphere(ball) using macro in c language .

#include <math.h>  //header file for math functions

#define pi 3.1415     //using macro

#include <stdio.h>  //header file for printf() or scanf()

int main()   //main function

{  

   double radius;  //radius is a double type variable

   float surface_area, vol;    //surface_area andvolume is a float type variable

   printf("Enter the radius of the sphere : \n");     //printf() is use to print an output

   scanf("%lf", &radius);   //scanf() is use to take input from the user

   surface_area =  4 * pi * pow(radius,2);

   vol = (4.0/3) * pi * pow(radius,3);

   printf("The Surface area of the sphere is: %.3f", surface_area); // display surface area

   printf("\n Volume of the sphere is : %.3f", vol); // display volume

   return 0;  

}

Output:

Enter radius of the sphere : 4.4

Surface area of sphere is: 243.278

Volume of sphere is : 356.807

Explanation:

Here in this program  we  include the header file math.h and include the macro pi. after that taking the user input in radius and calculating the surface area and volume of sphere and finally display the result.

4 0
2 years ago
Which of the following experiences is considered a simulation?
Butoxors [25]

Answer:

c

Explanation:

3 0
3 years ago
ENG103 DISCUSSION BOARD 6
amm1812
The proper citation for your course of study -computer related- is APA (American Psychological Association)  format. This citation format allows us to state the publication date, title , and authors in an organized and short fashion. All scholarly reports that are technology or psychology based, should be cited in APA format. 

<span>I know this because it is the format I use for all of my college courses which are all Computer/Technology related. </span>
3 0
3 years ago
Other questions:
  • How do you fix this windows 7 screen​
    8·1 answer
  • What step can Miguel take to solve his dilemma? Miguel is working on a project that requires him to switch back and forth freque
    12·2 answers
  • 9. The voltage of a replacement capacitor must
    11·1 answer
  • . Explain and demonstrate the functionality of timer devices in an embedded system[
    9·1 answer
  • Global address list characteristics
    11·1 answer
  • If a document is stored on a file server but team members can edit the document​ anonymously, the content on the file server is:
    14·1 answer
  • 10. Two technicians are discussing recycling specifications for refrigerant. Technician A says that refrigerant oil with 5,000 p
    9·1 answer
  • Three types of keys on the keyboard​
    15·2 answers
  • True or Fale A criminal defense attorney's main focus is to convict the accused of a crime, and a state prosecutor is to defend
    12·2 answers
  • A____consists of many users and their information.​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!