+44

Input we get is initially in which datatype.?

when we take an input by using input function. in python # unit = input("Enter a number ") unit is in which datatype.? is it a string? integer? or whaat.? explain me if you can please!😊

5/11/2018 7:59:24 AM

Paul

56 Answers

New Answer

+67

#readthedocs https://docs.python.org/3/library/functions.html#input "The function then reads a line from input, converts it to a string..."

+48

Its Obviously "String" 😊 You can even check yourself -> use type() function >>> type(input()) hello <class 'str'> >>> type(input()) 123 <class 'str'> >>>

+18

It contain string data type.you can convert this data type into another data type using functions. print(int(input())) #Now input contain only integer data type.

+13

What ever we 📝 write in a input it will give us a class<'str'> 📨 but when we need othera like float, int etc we have to use TYPE CONVERSION like:- int(input()) 😈

+11

In my humble opinion, I think that the initial type which you have entered your data is string, because when you wants to type a Integer, you put before the data to enter, so the type of data which you needs. In other languages stronger typed you must specify the data type which you enter, so the computer can reserve memory size to this variable. I think it's the reason because python doesn't ask for the data type.

+9

If I'm correct, the input() function reads the bytes representing the characters from the console buffer, and then encodes them into a string.

+8

+8

string

+7

You can find out the type being used/returned with the type() function. In this case: print(type(input("Enter something:"))) <class 'str'> Which will show that a string class is being returned.

+7

The Python input function reads a line as text, so the type is string, but you can easily transform it with the methods int, float, etc. Example: text = input("Enter some text") num = int(input("Enter any integer"))

+6

In PY if you don't define your datatype it will take input as string😊😊 but you can convert it

+6

+5

In developer Mozilla ..luck!

+5

Width print(type(input())) you will see it

+5

it actually a String which can be converted to other data type

+5

+4

+4

It is a string data type.

+4

yeh this func. get inputs as a String but if you want input as int just do like this: num1 = int(input("enter a number")) and if you type 2 then the type of the 2 is an Integer not "2" anymore

+4

input byte binary recognition equals text { shell } before converting to either string or integer output in byte binary recognition