Basics of Python's object and data structures
Hello 👋👋👋 i hope you are doing well. It was a wonderful day for me because I got to meet my nephew for the first time. I have seen a lot of his pictures, but seeing him in person was a special feeling to me.
“Running Python Code” source and “A Python Programming Language Introduction and Installation Guide”source were topics I covered in may earlier blogs. As a result, I made the decision to pick up where I left off. The link is provided above in case you are interested in taking a look.
The fundamental building blocks of larger pieces of code are data types. I will go through some fundamental Python data types down below.
Whole numbers are considered integers. Examples include 5, 10, 8, and so on. Python programming classifies any whole number you can imagine as an integer.
FLOATING POINT (float)
In Python programming, a floating point is any number with a decimal point, such as 8.2, 1.5, or 3.0.
3.0, which is also known as 3 becomes a floating point whenever the point is signified.
Strings are lists of objects that are double- or single-quoted, such as "man," "book," "Shamzy," "son," "1," etc. The single or double quotes are what distinguish an integer from a string.
LISTS ( list)
A list is an ordered grouping of items that uses commas and square brackets to group related items together. An example of this is [1, "book", 1.1], where we can see that the values in the square brackets correspond to an integer, a string, and a floating point, respectively.
Contrary to lists, dictionaries are unordered key-value pairs that use braces and are not well organized. "Goat": "name," "book": "store,"
The term "tuple" refers to an ordered, immutable list of Python objects.
Due to their immutability, tuples cannot be changed after they have been generated. Parentheses are used to define tuples ().
Sets simple refer to an unordered group of distinct items that are separated by commas and enclosed in braces ().
The logical value of a boolean is a True or False indication. True is denoted with a capital "T," while false is denoted by a capital "F."
CONDITIONS FOR SELECTING A VARIABLE NAME
Follow these guidelines to avoid mistakes when programming in Python:
- Names cannot begin with a number, for example. 1Alex. Instead of using a space in a name, use an underscore. For instance:
last letter (incorrect ❌❌❌)
last_letter (correct✅✅✅ )
- Avoid using any of the following symbols:
/?|()[email protected]#$ %&*+- >
- As much as possible , always use small letters in writing names
- Avoid using terms like "int," "float," "str," "list," "dict," "tup," "set," "bool," etc. that have unique meanings in Python.
Thank you for reading, I will greatly appreciate your support and any comments, additions, and corrections.
Posted with STEMGeeks