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
abruzzese [7]
3 years ago
13

g Write a function called price_of_rocks. It has no parameters. In a while loop, get a rock type and a weight from the user. Kee

p a running total of the price for all requested rocks. Repeat until the user wants to quit. Quartz crystals cost $23 per pound. Garnets cost $160 per pound. Meteorite costs $15.50 per gram. Assume the user enters weights in the units as above. Return the total price of all of the material. For this discussion, you should first write pseudocode for how you would solve this problem (reference pseudocode.py in the Week 7 Coding Tutorials section for an example). Then write the code for how you would tackle this function. Please submit a Python file called rocks_discussion.py that defines the function (code) and calls it in main().
Computers and Technology
1 answer:
Scilla [17]3 years ago
4 0

Answer:

<u>The pseudocode:</u>

FUNCTION price_of_rocks():

  SET total = 0

  while True:

      INPUT rock_type

      INPUT weight

      if rock_type is "Quartz crystals":

         SET total += weight * 23

      elif rock_type is "Garnets":

         SET total += weight * 160

      elif rock_type is "Meteorite":

         SET total += weight * 15.50

       

       INPUT choice

       if choice is "n":

           break

 

   RETURN total

END FUNCTION

<u>The code:</u>

def price_of_rocks():

   total = 0

   while True:

       rock_type = input("Enter rock type: ")

       weight = float(input("Enter weight: "))

       

       if rock_type == "Quartz crystals":

           total += weight * 23

       elif rock_type == "Garnets":

           total += weight * 160

       elif rock_type == "Meteorite":

           total += weight * 15.50

           

       choice = input("Continue? (y/n) ")

       if choice == "n":

           break

   

   return total

print(price_of_rocks())

Explanation:

Create a function named price_of_rocks that does not take any parameters

Initialize the total as 0

Create an indefinite while loop. Inside the loop:

Ask the user to enter the rock_type and weight

Check the rock_type. If it is "Quartz crystals", multiply weight by 23 and add it to the total (cumulative sum). If it is "Garnets", multiply weight by 160 and add it to the total (cumulative sum). If it is "Meteorite", multiply weight by 15.50 and add it to the total (cumulative sum).

Then, ask the user to continue or not. If s/he enters "n", stop the loop.

At the end of function return the total

In the main, call the price_of_rocks and print

You might be interested in
How does the post process alert the user if it detects a hardware problem during the post process?
Lesechka [4]
As a Alert down by the bar under where it says start I would think.
6 0
3 years ago
Many digital libraries have much more information than traditional libraries
Grace [21]

Answer:

However, despite 10 great breakthroughs of 2018 in technology, traditional libraries are still around – the British Library in London, the Library of Congress in Washington, D.C., the New York Public Library, the Bavarian State Library and many more which you can find in the list of 25 most famous libraries of the world. Although they don’t shy away from implementing some of the novelties into their structure and organization – all of them have quick access to the Internet. Well, why is it so? Is it going to keep that way? Just like in case with any other topic, making predictions is an ungrateful task, for the world is most likely to develop in the least predictable way – just like it always does. Let’s look at the ‘battle’ between digital and traditional libraries.

Explanation:

5 0
3 years ago
As the demand for goods and services increases, job growth _____. a. increases b. decreases c. remains the same d. none of the a
Dmitriy789 [7]
The answer is A. Increases, as more manpower is needed if demand increases.
6 0
3 years ago
Read 2 more answers
If a class has member variables that are pointers, you must ensure that you implement ____.
DedPeter [7]

Answer:

objects

Explanation:

pointer are used for the objects

5 0
3 years ago
Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
r-ruslan [8.4K]

Answer:

switchboard

Explanation:

The option that he should implement would be a switchboard interface design. These design structures for graphic user interfaces use a single main page, large icons/buttons, a fixed navigation menu, and all the necessary functionality right in front of the user. This design is made with simplicity in mind in order to make it as easy as possible for a new user to pick up and efficiently and intuitively navigate the user interface. Therefore, since Calvin needs a simple yet professional design, this would be the best implementation.

7 0
3 years ago
Read 2 more answers
Other questions:
  • I NEED IT FOR TODAY FOR KEYBOARDING TEST! GIVE ME CORRECT ANSWER PLZ!
    12·2 answers
  • What is a collection of computer programs that administer the hardware and software of a computer so that they work properly?
    7·1 answer
  • Which of the following is true about scalability?
    9·1 answer
  • 1.) Florida has ____________ roads that are designated as part of the National Highway System.
    12·1 answer
  • ___________ is related to mass, but also includes the gravitational pull of the Earth.
    14·1 answer
  • This finding maximum number function will keep on going until we reach at the last value
    12·1 answer
  • Describe the main roles of the communication layer, the network-wide state-management layer, and the network-control application
    15·1 answer
  • Wha are the types of slide show? define​
    10·1 answer
  • What is a closed system?​
    7·1 answer
  • scheduling is approximated by predicting the next CPU burst with an exponential average of the measured lengths of previous CPU
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!