Answer changing by omitting 'type'

image
Hello sir,
In the above code, its not answering correctly until i add “type” infront of num in line 3 (comparing to int). Could you please explain why simple num is not being able to be compared to int?

If you want to compare num==x.
Then x must be a numeric value or a Boolean.
example :- num==5 , or num==True

If you want to compare with the type of the variable then,

type(num)==int.
or type(num)==float etc.

as you are comparing the type with the variable type.

Note :- Like quantities are comparable, unlike quantities are not.
here num variable may be numeric/character but int is type of that variable.

Kindly refer to the Python lectures ASAP, it is explained there.

All the best!