+ 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?
6 odpowiedzi
+ 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
+ 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.
+ 2
Hi Slick thanks for your answer .....was a Lil bit helpful for me 🙂
+ 2
Lothar thanks for helping me ....🙂
+ 1
Because 8 is an integer. What do you mean? That IS the data type
https://code.sololearn.com/clY1L4uDf7wg/?ref=app
+ 1
Thank you so much Mohamed Ayaou for the simplest and understandable explanation. I got your point. Thank you once again 🙂