I’ve coded in python before for my university course but never really understood it- I’m trying to do that now.
I’m trying to understand why the following code gives an error:
import numpy as np
np.dtype(20)
Which gives the error “Cannot interpret ‘20’ as a data type”.
I am confused by this because data types include integers and floats. What I was expecting was for this to tell me whether when I type ‘20’, is this being read as an integer or a float?
There is a question posted here which has a similar title but it’s in the context of an error obtained by creating neural networks and honestly none of the answers really explain anything. The closest one gets to an explanation is ‘the second parameter should be a data type and not a number’ but I don’t understand this… surely there are no such thing object types as ‘numbers’ in python and everything that looks like a ‘number’ is either an integer or a float to some precision from the perspective off the computer?
I would greatly appreciate if someone could help me understand what is happening when I type ‘20’ into python because it doesn’t seem to be what I thought.