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
Licemer1 [7]
3 years ago
15

If we were ever to use this pizza ordering program again, we would want to use mainline logic to control its execution. The way

it is written, it will automatically execute as soon as it is imported.
Re-write this program, enclosing the top level code into the main function. Then execute the main function. Enter appropriate input so the output matches that under Desired Output.
# Define Function
def pizza(meat="cheese", veggies="onions"):
print("You would like a", meat, "pizza with", veggies)
# Get the User Input
my_meat = input("What meat would you like? ")
my_veggies = input("What veggie would you like? ")
# Call the Function
pizza(meat=my_meat, veggies=my_veggies)
desired output:
What meat would you like? cheese
What veggie would you like? onions
You would like a cheese pizza with onions
2) We want to generate 5 random numbers, but we need the random module to do so. Import the random module, so the code executes.
# Define main function
def main():
print("Your random numbers are:")
for i in range(5):
print(random.randint(1, 10))
# Call main function
main()
desired output:
Your random numbers are:
[x]
[x]
[x]
[x]
[x]
Computers and Technology
1 answer:
Maru [420]3 years ago
7 0

Answer:

Explanation:

The Python program has been adjusted. Now the pizza ordering function is called from the main() method and not as soon as the file is imported. Also, the random package has been imported so that the random.randint(1,10) can correctly create the 5 random numbers needed. The code has been tested and the output can be seen in the attached image below, correctly matching the desired output.

import random

def pizza(meat="cheese", veggies="onions"):

   print("You would like a", meat, "pizza with", veggies)

def main():

   # Get the User Input

   my_meat = input("What meat would you like? ")

   my_veggies = input("What veggie would you like? ")

   # Call the Function

   pizza(meat=my_meat, veggies=my_veggies)

   print("Your random numbers are:")

   for i in range(5):

       print(random.randint(1, 10))

# Call main function

main()

You might be interested in
Leah deals with several file conversions every day.
Lelechka [254]
That’s not a question but good for her
5 0
3 years ago
What keyboard command opens the Go To dialog box?
Harlamova29_29 [7]

If you mean the search for a phrase or word function on a page,

Left Ctrl + F

7 0
4 years ago
Read 2 more answers
Suppose that a computer can run an algorithm on a problem of size 1,024 in time t. We do not know the complexity of the algorith
Setler79 [48]

Answer:

Time Complexity of Problem - O(n)

Explanation:

When n= 1024 time taken is t. on a particular computer.

When computer is 8 times faster in same time t , n can be equal to 8192. It means on increasing processing speed input grows linearly.

When computer is 8 times slow then with same time t , n will be 128 which is (1/8)th time 1024.

It means with increase in processing speed by x factor time taken will decrease by (1/x) factor. Or input size can be increased by x times. This signifies that time taken by program grows linearly with input size n. Therefore time complexity of problem will be O(n).

If we double the speed of original machine then we can solve problems of size 2n in time t.

5 0
4 years ago
What would a good digital citizen do in the following situation? Nick sees that his classmate left her email account open on a s
Inessa [10]
1234567898765432123456789876543212345678987654321
3 0
3 years ago
Five programs are currently being run in a computer. Program 1 is using 10 GiB of RAM, program 2 is using 5 GiB of RAM, program
muminat

Virtual memory could be used to allow program 5 to access RAM without any of the data from the other four programs being lost because it is one that tend to allows the system to give all of the process its own memory space that is said to be  isolated from the other processes.

<h3>How is virtual memory used instead of RAM?</h3>

A system is known to make use of a virtual memory and this is one that tend to make use of a section of the hard drive to act like the RAM.

With the use of virtual memory, a system can be able to load bigger or a lot of programs running at the same time, and this is one that tends to hep one to work as if it has more space, without having to buy more RAM.

Therefore, Virtual memory could be used to allow program 5 to access RAM without any of the data from the other four programs being lost because it is one that tend to allows the system to give all of the process its own memory space that is said to be  isolated from the other processes.

Learn more about virtual memory from

brainly.com/question/13088640

#SPJ1

6 0
1 year ago
Other questions:
  • Why don't we get together to watch the Academy Awards?
    15·2 answers
  • Can someone please help me with this question?
    12·1 answer
  • Recall the insertion-sort-like algorithm in Problem 4 from Homework 2, where you know that certain pairs of contiguous items in
    15·1 answer
  • Write the Python code to implement each step of the following algorithm. Your code should use descriptive variable names and per
    7·1 answer
  • What is technology?
    11·1 answer
  • The theory of logic set the foundation for what aspect of computing today?
    11·1 answer
  • Yuri, a medical assistant, has been asked to send an account of a patient's last office visit to another doctor's office. The te
    6·2 answers
  • Why do certain words change color in Python?
    6·1 answer
  • C#
    10·1 answer
  • What is a best practice when approaching an automation effort?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!