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
In a(n) _____, the web becomes an integral part of the application, rather than just a communication channel, and systems analys
IRISSAK [1]

In an <u>Internet-based system</u>, the web becomes an integral part of the application, rather than just a communication channel, and systems analysts need new application development tools and solutions to handle the new systems.

d) Internet-based system

<u>Explanation:</u>

Web information system, or web-based information system, is a data framework that utilizes Internet web advancements to convey data and administrations, to clients or other data frameworks/applications.

It is a product framework whose primary intention is to distribute and keep up information by utilizing hypertext-based standards. In an Internet-based system, the Web turns into a fundamental piece of the application, instead of only a correspondence channel, and frameworks investigators need new application advancement instruments and solutions to handle the new systems.

7 0
3 years ago
Entering the formula =SUM(C5:C18), in cell C19 will result in which of the following?
Greeley [361]
I am not sure what the 'following's are
but it should result the sum of all cells between and including C5 and C18.

5 0
3 years ago
What is most likely kept in as database
belka [17]
Sales reports,employee records,logged passwords   somebody has already asked this question
4 0
3 years ago
porfavor no es una pregunta dificil, nisiquiera es de una tarea, hace poco mi computador windows 10 no recibia el sonido de mis
amid [387]

Answer:

he intentado encender la computadora mono

Explanation:

6 0
3 years ago
Network id is 192.168.10.32/28. what would be the ip address, if you assign the last available ip address in the range
Yakvenalex [24]
192.168.10.47 would be the multicast address for this network.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Name size of machine screw that is used to secure switches and receptacles to device boxes
    13·1 answer
  • Data warehousing and data mining mean the same thing when applied to CRM
    7·2 answers
  • What Linux services can pose a problem when attempting to reach remote host on a network?
    5·2 answers
  • What document type would be best to communicate sales items from a business to potential customer?
    12·1 answer
  • In a @return tag statement the description:
    13·2 answers
  • What could be one rule to help your friend to blog safely
    6·2 answers
  • Why is a high-quality bond typically considered a lower-risk investment than a stock
    10·2 answers
  • What is the output?<br> &gt;&gt;&gt; phrase = "hello mom"<br> &gt;&gt;&gt; phrase upper()
    6·2 answers
  • How do i fix this to make it run ???
    9·1 answer
  • Easy way of communication with people is one disadvantage of a network. *<br><br> 1.True<br> 2.False
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!