226k views
1 vote
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. Remember that print() automatically adds a newline.

User Joie
by
3.2k points

2 Answers

6 votes

Answer:

Step-by-step explanation:

def print_popcorn_time(bag_ounces):

if bag_ounces < 3:

print("Too small")

elif bag_ounces > 10:

# Use of 'if' for this portion, will only yield a test aborted for secondary tests

print("Too large")

else:

print(str(6 * bag_ounces)+" seconds")

user_ounces = int(input())

print_popcorn_time(user_ounces)

User Saladin Akara
by
3.7k points
3 votes

Answer:

In Python:

def print_popcorn_time(bag_ounces):

if bag_ounces < 3:

print("Too small")

if bag_ounces > 10:

print("Too large")

else:

print(str(6 * bag_ounces)+" seconds")

Step-by-step explanation:

This defines the function

def print_popcorn_time(bag_ounces):

This checks if bag_ounces < 3

if bag_ounces < 3:

If yes, it prints too small

print("Too small")

This checks if bag_ounces > 10

if bag_ounces > 10:

If yes, it prints too big

print("Too large")

If otherwise,

else:

Multiply bag_ounces by 6 and print the outcome

print(str(6 * bag_ounces)+" seconds")

User Wazelin
by
3.6k points