+ 1

Why it prints "class int"?

a=8 print(type(a)) Output <class 'int'> Coders, Help me to understand that why is written "class" in output?why Not data type?

16th Apr 2022, 12:47 PM
Nom Nom
Nom Nom - avatar
6 Respostas
+ 4
It will be strange for you as a starter, but every data type is a class, for example: 8 is a class called int and [5,7,8] is a class called list and "hello" is a class called str an so on. you will learn more about classes in the oop lesson
16th Apr 2022, 1:51 PM
Mohamed Ayaou
+ 2
Shivani Goyal , (first line) the code defines an integer variable and assigns the value of 8 (second line) the builtin function type() is used by giving the variable name as argument. type() returns the the data type of the argument, which is an instance of class 'int'. this will be output by the print() function.
16th Apr 2022, 1:49 PM
Lothar
Lothar - avatar
+ 2
Hi Slick thanks for your answer .....was a Lil bit helpful for me 🙂
16th Apr 2022, 2:07 PM
Nom Nom
Nom Nom - avatar
+ 2
Lothar thanks for helping me ....🙂
16th Apr 2022, 2:07 PM
Nom Nom
Nom Nom - avatar
+ 1
Because 8 is an integer. What do you mean? That IS the data type https://code.sololearn.com/clY1L4uDf7wg/?ref=app
16th Apr 2022, 1:46 PM
Slick
Slick - avatar
+ 1
Thank you so much Mohamed Ayaou for the simplest and understandable explanation. I got your point. Thank you once again 🙂
16th Apr 2022, 2:06 PM
Nom Nom
Nom Nom - avatar