Variable and Data Type
You have learnt about the following data type in Python.
- int – Used for whole numbers (e.g. 1, 10, 100)
- float – Used for decimal numbers (e.g 1.4, 2.5, 3.0)
- str – Used for any textual data (e.g. ‘John, “Peter”, “Male”)
You can use both single quote (‘john’) or double quote (“john”)
In Java, there is similar concept of data type as well.
- int – Used for whole numbers as well
- float, double – Used for decimal numbers
In this course, for simplicity, we will always use double to store decimal numbers.
- String – Used for textual data. Take note that only double quote is allowed (“john”)