Single Choice Not Set

QA user-specified value can be assigned to a variable with ______ function.

ID: #3394 Python Basic MCQ 1,713 views
Question Info
#3394Q ID
Not SetDifficulty
Python Basic MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A user
  • B enter
  • C input
  • D value
Correct Answer

Explanation

The input() function is used to accept input from the user during program execution. By default, the value entered by the user is returned as a string and can be assigned to a variable.

Example:

color = input("What color is rose?: ")
print("Rose is", color)

Output:

What color is rose?: red
Rose is red

If you need to work with numbers, you must convert the input to the required data type using functions such as int() or float().

Example:

age = int(input("Enter your age: "))
print(age + 1)

The other options are incorrect because user, enter, and value are not built-in Python functions for accepting user input.

Therefore, the correct answer is Option C) input().

Share This Question

Challenge a friend or share with your study group.