11.0k views
5 votes
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

User Gomez NL
by
4.5k points

2 Answers

0 votes

Answer:

The other answer had some mistakes (i.e. capitalization when it should be lower case, etc.) that made it incorrect. Here is the updated answer:

Written in Python:

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" % bag_ounces)

user_ounces = int(input())

print_popcorn_time(user_ounces)

Step-by-step explanation:

User Thomas G
by
3.9k points
5 votes

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\\" % bag_ounces)

Step-by-step 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 \\ for a new line in the final print statement
User Mujtaba Hassan
by
5.1k points