There are three types of data in Python. They are:
1. String
2. Integers
3. Float
-----------------------------------------------
String refers to text.
To declare a string, you can do variableName = '[initial value]' or variableName = "[initial value]"
Example:
userName = 'bee'
userName = "bee"
userAge = '25'
Because we wrote userAge = '25', userAge is a string. Furthermore, if userAge = 25, userAge is an integer.
We can combine substrings by using the concatenate sign, such as:
"dingus" + "Bringus" is equivalent to "dingusBringus".
-------------------------------------------------
Integers are whole numbers that can be positive or negative, such as -2, -1, 0, 1, 2, etc.
To declare an integer in Python, simply write variableName = [initial value]
i.e. userAge = 20
-------------------------------------------------
Float are decimal numbers that can be both positive and negative, such as 54.35, -12.4657, etc.
To declare a float in Python, we do variableName = [initial value]
For example, userWeight = 75.4
No comments:
Post a Comment