Computer Science, asked by hhjbiu, 7 months ago

If no data type is mentioned with the input function then Python Interpreter will consider it as?

Answers

Answered by Equestriadash
6

If there is no data type mentioned with the input function, the interpreter will treat it as a string value.

For example:

string = input("Enter a string value: ")

print(string*2)

This will print the string two times. Since we tried to repeat it twice with the '*' operator.

string = int(input("Enter a string: "))

print(string*2)

Output:

Traceback (most recent call last):

 File "main.py", line 1, in <module>

   string = int(input("Enter a string: "))

ValueError: invalid literal for int() with base 10: 'Hello and Welcome!'

You cannot perform calculations with string values.

Similar questions