exam questions

Exam PCEP-30-02 All Questions

View all questions & answers for the PCEP-30-02 exam

Exam PCEP-30-02 topic 3 question 31 discussion

Actual exam question from Python Institute's PCEP-30-02
Question #: 31
Topic #: 3
[All PCEP-30-02 Questions]

You have the following file.

You want the following output: The average score for Peter is 200.00.
Which command do you have to execute in the command line?

  • A. python index.py Peter 100
  • B. python index.py Peter 100 200 300
  • C. The code is erroneous.
  • D. python index.py Peter 100 200
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
4ba36e7
1 month, 3 weeks ago
Selected Answer: B
B. python index.py Peter 100 200 300 argv = ['index.py', 'Peter', '100', '200', '300'] Loop runs i = 2, 3, 4 → sums 100+200+300 = 600 (len(argv) - 2) = 5 - 2 = 3 → average = 200.00
upvoted 1 times
...
masrur.sattorov
3 months, 2 weeks ago
Selected Answer: B
The averge score for Peter is 100.00 ---> A not correct The averge score for Peter is 200.00 ---> B correct The averge score for Peter is 150.00 ---> C not correct. We have to test in command-line (cmd) not in IDE.
upvoted 1 times
...
mynutelynx
5 months, 2 weeks ago
Selected Answer: C
if Line 1 is included in the file, yes it is syntax error
upvoted 1 times
...
mynutelynx
5 months, 2 weeks ago
Selected Answer: B
answer is B, there is no error in code
upvoted 1 times
...
Donny_575
8 months, 1 week ago
Selected Answer: C
C: Tested in Pycharm and results in an IndexError
upvoted 1 times
...
akumo
8 months, 1 week ago
Selected Answer: C
C. The code is erroneous.
upvoted 1 times
...
5c81923
8 months, 3 weeks ago
Selected Answer: C
This code is erroneous. Line 1 will throw a syntax error.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...