nerdexam
Python_Institute

PCEP-30-02 · Question #248

PCEP-30-02 Question #248: Real Exam Question with Answer & Explanation

The correct answer is C. 1|%-20s 2|%4.1f. See the full explanation below for the reasoning.

Question

The ABC Company is building a basketball court for its employees to improve company morale. You are creating a Python program that employees can use to keep track of their average score. The program must allow users to enter their name and current scores. The program will output the user name and the user's average score. The output must meet the following requirements:
  • The user name must be left-aligned.
  • If the user name has fewer than 20 characters, additional space must be added to the right.
  • The average score must have three places to the left of the decimal point and one place to the right of the decimal (xxx.x). What would you insert instead of ??? and ??? ?
1 name = input('What is your name?') 2 3 score = 0 4 count = 0 5 while score != -1: 6 score = int(input('Enter your scores: (-1 to end)')) 7 if score == -1: 8 break 9 sum += score 10 count += 1 11 average = sum / count 12 print('???', 'your average score is:', '??? %' (name, average))

Options

  • A1 |%-20f 2|%4.1s
  • B1|%-20f 2|%4.1
  • C1|%-20s 2|%4.1f
  • D1|%-20f 2|%1.4s

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice