+ 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!😊

11th May 2018, 7:59 AM
Pauly😊💖
Pauly😊💖 - avatar
58 Respostas
+ 67
#readthedocs https://docs.python.org/3/library/functions.html#input "The function then reads a line from input, converts it to a string..."
11th May 2018, 8:19 AM
Burey
Burey - avatar
+ 48
Its Obviously "String" 😊 You can even check yourself -> use type() function >>> type(input()) hello <class 'str'> >>> type(input()) 123 <class 'str'> >>>
13th May 2018, 4:07 PM
OR!ON 🛡️
OR!ON 🛡️ - avatar
+ 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.
13th May 2018, 3:52 PM
Maninder $ingh
Maninder $ingh - avatar
+ 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()) 😈
13th May 2018, 5:26 PM
Mr.ASDF
Mr.ASDF - avatar
+ 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.
13th May 2018, 4:45 PM
David Rueda 🇪🇸
David Rueda  🇪🇸 - avatar
+ 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.
13th May 2018, 4:54 PM
Mante
Mante - avatar
+ 8
string
13th May 2018, 3:05 PM
Bala Krishnan V
Bala Krishnan V - avatar
+ 8
string
13th May 2018, 3:35 PM
Pink Floyd
Pink Floyd - avatar
+ 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.
13th May 2018, 5:32 PM
Stephen
Stephen - avatar
+ 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"))
13th May 2018, 9:31 PM
Yuhiro
Yuhiro - avatar
+ 6
In PY if you don't define your datatype it will take input as string😊😊 but you can convert it
13th May 2018, 5:40 PM
Madan Choudhary
Madan Choudhary - avatar
+ 6
str
13th May 2018, 11:34 PM
ManYin Cheung
ManYin Cheung - avatar
+ 5
In developer Mozilla ..luck!
13th May 2018, 4:19 PM
Alan Carreño Fiestas
Alan Carreño Fiestas - avatar
+ 5
Width print(type(input())) you will see it
13th May 2018, 10:03 PM
Jorge
+ 5
it actually a String which can be converted to other data type
15th May 2018, 6:02 PM
George Victor Uche
George Victor Uche - avatar
+ 5
string
15th May 2018, 10:34 PM
Muazzam Adam
Muazzam Adam - avatar
+ 4
string
13th May 2018, 7:57 PM
Patrik Björkman
Patrik Björkman - avatar
+ 4
It is a string data type.
14th May 2018, 3:12 AM
Frank Bigus
Frank Bigus - avatar
+ 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
14th May 2018, 9:39 AM
moli42
moli42 - avatar
+ 4
input byte binary recognition equals text { shell } before converting to either string or integer output in byte binary recognition
16th May 2018, 12:01 AM
BroFar
BroFar - avatar