It's my first time to write something like an article, so it may be difficult to see or understand, but please understand that I will continue to devote myself.
Unlike java, variables can be defined with num = 1`` str =" aaa "
instead of int num = 1
or String str =" aaa "
data = 1 data ="aaa" print(data)
Even if you put a character string after putting an integer like the above in a variable, it works without problems. Do I need to be careful when handling data as it seems to work somehow if I'm not careful? ??
There is a type () function in the way to check the type of data
num = 1
num2 = 1.5
str ="aaa"
listData = [0,1,2]
print(type(num))
print(type(num2))
print(type(str))
print(type(listData))
#=> <class 'int'>
#=> <class 'float'>
#=> <class 'str'>
#=> <class 'list'>
Addendum: I would like to investigate both java and python on my own, including the content that you commented on the detailed content of the data type.
Recommended Posts