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
Nataly [62]
3 years ago
5

Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than

10, print "Too large". Otherwise, compute and print 6 * bag_ounces followed by "seconds". End with a newline. Sample output with input: 7 42 seconds
Computers and Technology
1 answer:
Lynna [10]3 years ago
4 0

Answer:

def print_popcorn_time(bag_ounces):

 if bag_ounces<3:

   print("Too Small")

 elif bag_ounces>10:

   print("Too Large")

 else:

   bag_ounces = bag_ounces*6

   print("%s Seconds\n" % bag_ounces)    

Explanation:

  • Using Python Programming Language
  • The function is defined to accept an int parameter
  • Within the function body, if...elif and else statements are used to print the desired output
  • note the use of the %s placeholder (formated output) and \n for a new line in the final print statement
You might be interested in
Write the definition of a function divide that takes four arguments and returns no value . The first two arguments are of type i
Nastasia [14]

Answer:

#include <iostream>

using namespace std;

void divide(int numerator, int denominator, int *quotient, int *remainder)

{

*quotient = (int)(numerator / denominator);

*remainder = numerator % denominator;

}

int main()

{

int num = 42, den = 5, quotient=0, remainder=0;

divide(num, den, &quotient, &remainder);

 

return 0;

}

Explanation:

The exercise is for "Call by pointers". This technique is particularly useful when a variable needs to be changed by a function. In our case, the quotient and the remainder. The '&' is passing by address. Since the function is calling a pointer. We need to pass an address. This way, the function will alter the value at the address.

To sum up, in case we hadn't used pointers here, the quotient and remainder that we set to '0' would have remained zero because the function would've made copies of them, altered the copies and then DELETED the copies. When we pass by pointer, the computer goes inside the memory and changes it at the address. No new copies are made. And the value of the variable is updated.

Thanks! :)

8 0
3 years ago
You are to design class called Employee whose members are as given below:
frozen [14]

Answer:

//The Employee Class

public class Employee {

   char name;

   long  ID;

//The constructor  

public Employee(char name, long ID) {

       this.name = name;

       this.ID = ID;

   }

//Method Get Person

   public void getPerson (char newName, long newId){

       this.ID = newName;

       this.ID = newId;

   }

//Method Print

   public void print(){

       System.out.println("The class attributes are: EmpName "+name+" EmpId "+ID);

   }

}

The working of the class is shown below in another class EmployeeTest

Explanation:

public class EmployeeTest {

   public static void main(String[] args) {

       Employee employee1 = new Employee('a', 121);

       Employee employee2 = new Employee('b', 122);

       Employee employee3 = new Employee('c', 123);

       employee1.print();

       employee2.print();

       employee3.print();

   }

}

In the EmployeeTest class, Three objects of the Employee class are created.

The method print() is then called on each instance of the class.

6 0
3 years ago
What is the maximum rate at which computers A and B can communicate, via router X? (your answer should be in Mbps)
eduard
450Mbps on the 2.4GHz band and 1300Mbps on the 5GHz band
7 0
3 years ago
10.A chlorine ion (Cl-) would most likely bond with _____.<br><br> A.Cl-<br> B.Mg<br> C.K+<br> D.O
andrezito [222]
B. Mg
Hope this helps ☺
6 0
3 years ago
In which of the following scenarios would you choose to embed versus import data?
Mrrafil [7]

Answer:

B.)You want to maintain connections with external files

Explanation:

These are the options for the question

A.)You do not want to save the original data sources.

B.)You want to maintain connections with external files

C.)You want to reduce file size

Embedding data can be regarded as insertion of objects( embedded object) such as spreadsheet into a word-processor so that it can be edditted.

Data Import can be regarded as ways that give room for uploading of data

from external sources , then combine it with data that is been collected via Analytics.

6 0
3 years ago
Other questions:
  • The length of a hailstone sequence is the number of terms it contains. For example, the hailstone sequence in example 1 (5, 16,
    9·1 answer
  • Using your own computer, give the name of the operating system that runs it and give examples of five legal file names. Then cre
    13·1 answer
  • A type of bridge that relies on a curved, semi-circular structure for support
    5·1 answer
  • What keeps unauthorized internet users out of private intranets?
    7·1 answer
  • There's a rising issue with bots sending links starting with 'bit'. These links are dangerous and harmful for any computer or de
    6·2 answers
  • What is the benefit of hosting a website on a personali
    6·1 answer
  • The choice of database does not have any impact on the relevancy of search results?
    13·1 answer
  • A while loop is frequently used to ______________ data.
    5·1 answer
  • Which of the following could be a method for an object-oriented class called Student?
    8·1 answer
  • This function returns the length of a string:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!