📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Which of the following function in python is used to

    read keyboard input?
    A cin Correct Answer Incorrect Answer
    B gets Correct Answer Incorrect Answer
    C input Correct Answer Incorrect Answer
    D scanf Correct Answer Incorrect Answer

    Solution

    Why this is correct:
    input() is the built-in Python function that reads a line from standard input (keyboard) and returns it as a string (in Python 3). It’s the standard way to get user input. Why the others are wrong: 1.      cin is from C++ (std::cin), not Python. 2.      gets is a C function (unsafe and deprecated) — not Python. 3.      scanf is a C function (formatted input) — not Python.

    Practice Next
    More IT Operating System Questions

    Relevant for Exams:

    ask-question