Data Type
Different numbers, alphebets, lists are called 'Data Types'.
For example, putting anything inside ""
is a string.
weather = "sunny"
Finding out the data type
Using type()
function, we can find out the data type of the variable.
print(type("Hello, World"))
<class 'str'>
is the result of running the code above.
It means "Hello World"
is a string class, which basically means it is a string type.
Checking the data type
isinstance()
is a function that checkes if the variable is a sepcfici type.
Put the variable inside the parentheses, and the type of the variable inside the parentheses (2nd
The result will be either True
or False
Because "sunny"
is a string, isinstance("sunny", str)
will return True
.
str
. :::import Quiz from 'react-quiz-component';