If no data type is mentioned with the input function then Python Interpreter will consider it as?
Answers
Answered by
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
India Languages,
3 months ago
Science,
3 months ago
English,
3 months ago
English,
7 months ago
Social Sciences,
11 months ago
Math,
11 months ago