1. Home
  2. Data Science
  3. Python
  4. What does python -c 'print(1+1)' do?

Added 25 Nov 2026

What does python -c 'print(1+1)' do?

  1. Compiles a file
  2. Checks code style
  3. Runs the code string given on the command line Correct answer
  4. Clears the cache

Correct answer

C. Runs the code string given on the command line

5 views

MCQSEXAM

Explanation

The -c flag executes the Python code passed as a string.

Reference

Asked in: Python Interview Basics

https://docs.python.org/3/tutorial/introduction.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs