Good day geeks!
PYTHON UNLEASEH'D 06
This mediocre sounding blog is going to be interesting unlike its name I swear. No already known information here, not discussing basics, just (RARELY KNOWN) things for people shifting to python.
We have the following data types in python :
Text Type: str
Numeric Types: int, float, complex
Sequence Types: list, tuple, range
Mapping Type: dict
Set Types: set, frozenset
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview
None Type: NoneType
- Numeric Types
Integers – This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals). In Python, there is no limit to how long an integer value can be.
Float – This value is represented by the float class. It is a real number with a floating-point representation. It is specified by a decimal point.
Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation.
- Complex Numbers – A complex number is represented by a complex class. It is specified as (real part) + (imaginary part)j. For example – 2+3j
Program for complex numbers
AS MENTIONED, ONLY 'j/J' is allowed to represent imaginery part of complex number. Please try in your editor.
Python has class for each data type, as read above. Okay
I guess there must be some methods associated with each class. Lets search about this and explore.
FROM STACKOVERFLOW -
int is a class. The type of a class is usually type.
And yes, almost all classes can be called like functions. You create what's called an instance which is an object that behaves as you defined in the class. They can have their own functions and have special attributes.
(type is also a class if you're interested but it's a special class. It's a bit complicated but you can read more on it if you'll search for metaclasses)
We get plethora of methods and information🤯 about this 'int' class on writing help(int)
in notebook. That's more than enough, lets wrap up🤐. These numeric types are associated with their respective classes and what all variables we create are instances. These classes have methods. ✔✔
A good read on numeric data types of Python
We can use underscore as separators for big integer values like we use comma in maths.
Thanks for reading guys
If you liked the content, do react, or for any feedback/correction/suggestion feel free to reach out to me on Linkedin or can comment here...
Top comments (0)