Which code should you write at line 02?

You develop a Python application for your company.
You need to accept input from the user and print that information to the user screen.
You have started with the following code. Line numbers are included for reference only.

Which code should you write at line 02?
A. name = input
B. input(“name”)
C. input(name)
D. name = input()

microsoft-exams

2 thoughts on “Which code should you write at line 02?

  1. Suggested answer (B) will throw error :

    print(“What is your name”)
    input(“name”)
    print(name)

    Result:

    What is your name
    name gsb
    Traceback (most recent call last):
    File “sample.py”, line 3, in
    print(name)
    NameError: name ‘name’ is not defined

    Answer should be choice D

    print(“What is your name”)
    name = input()
    print(name)

    Result :
    What is your name
    gsb
    gsb

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.