Foundations-of-Computer-Science practice question 5 of 15
What will the output be of this line?
Full set: 71 questionsThe question is unanswerable as the line of code is missing. However, the "no output" option strongly implies the line was a comment. In Python, any line beginning with a hash symbol (#) is a comment. The interpreter ignores comments entirely during execution, so a line like # 20 + 5 would be valid but produce no output.
A. The string "20 + 5" would only be output if the code was an explicit print statement, such as print("20 + 5").
C. A comment is never displayed as output. The value 25 would be the output of print(20 + 5), not #25.
D. A line containing only a comment is syntactically correct in Python and would not raise a SyntaxError.
1. Python Software Foundation. (2023). The Python Language Reference, 2.1.5. Comments. Python 3.11.4 documentation. Retrieved from https://docs.python.org/3/reference/lexicalanalysis.html#comments
2. Van Rossum, G., Warsaw, B., & Coghlan, N. (2001). PEP 8 – Style Guide for Python Code. Python Enhancement Proposals. Retrieved from https://peps.python.org/pep-0008/#comments
Keep practicing
Take the free Foundations-of-Computer-Science practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Foundations-of-Computer-Science practice questions
- Question 1What is the purpose of a parameter in a function definition?
- Question 2What is the primary purpose of an operating system?
- Question 3Which action is taken if the first number is the lowest value in a selection sort?
- Question 4What will the expression fam[3:6] return?
- Question 6Which aspect is excluded from a NumPy array’s structure?
- Question 7Which of the following best defines an algorithm?
