Check form and intended meaning

A museum charges 6 dollars per admission plus a single booking fee of 2 dollars. Three Python fragments attempt to calculate the price of four admissions.


In Python, * means multiplication, multiplication occurs before addition, and parentheses group a calculation. print displays a value. A missing required operator makes a fragment invalid, so it produces no displayed number.


Fragment A


Python
count = 4
total = count * 6 + 2
print(total)


Fragment B


Python
count = 4
total = count * (6 + 2)
print(total)


Fragment C


Python
count = 4
total = count 6 + 2
print(total)


Complete the table. In the middle column, enter the exact whole number displayed, or enter invalid. In the last column, enter yes only if the fragment runs and calculates the stated pricing rule; otherwise enter no.

FragmentDisplayed number or invalidMeets pricing rule
A
B
C

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More What Is Programming? Questions: