Hey, you are at the right place if you want to learn the most important concepts of python. So, without any further delay let's get a dive into it…..
Many programming languages come and go, but only the strong one survives in the industry. Yes, we are talking about python! It is constantly rising in the industry and has proved to be known as one of the top programming languages in the world right now.
Python ranked #1 on the IEEE Spectrum list of top programming languages for 2019.
Top organizations of the world like Dropbox, Google, Quora, Mozilla, Hewlett-Packard, Qualcomm, IBM, and Cisco have shown faith in python.
According to Stack overflow python is the most popular language in 2020
As a Python expert, I believe that there are certain vital concepts or facts that every Python developer should know. All these were necessary concepts within the time I learned using Python as my foremost programming language.
Let’s get started with 11 concepts of Python you must learn….
-
Operators
Operators are special symbols that carry out operations on operands.
Let's explore arithmetic and assignment operators :
Arithmetic operators are used to performing mathematical operations like addition, subtraction, multiplication, etc.
For example:
x = 14
y = 4
# Add two operands
print('x + y =', x+y) # Output: x + y = 18
# Subtract right operand from the left
print('x - y =', x-y) # Output: x - y = 10
# Multiply two operands
print('x * y =', x*y) # Output: x * y = 56
# Divide left operand by the right one
print('x / y =', x/y) # Output: x / y = 3.5
Assignment operators are used to assigning values to variables. Let's try some more assignment operators.
For example:
x = 5
# x += 5 ----> x = x + 5
x +=5
print(x) # Output: 10
# x /= 5 ----> x = x / 5
x /= 5
For detailed knowledge visit Python Operators and learn about all operators in detail.
-
More about String
A Python string is a sequence of characters.
Python doesn’t have the char data-type as C++ or Java does
You can declare a Python string using either single quotes or double-quotes.
- >>> a='python is love'
- >>> print(a)
Python is love
- >>> a="python is love"
- >>> print(a)
Python is love.
know more about strings and different types of strings.
3. Python Iterators
A Python iterator returns us an iterator object- one value at a time. Let’s take an example of an iterator in python.
>>> iter_obj=iter([3,4,5])
>>> next(iter_obj)
3
>>> next(iter_obj)
4
>>> next(iter_obj)
5
>>> next(iter_obj)
Traceback (most recent call last):
File “<pyshell#560>”, line 1, in <module>
next(iter_obj)
StopIteration
For more details, check our Python Iterator tutorial.
4. Python loops
When you want some statements to execute a hundred times, you don’t repeat them 100 times. Think of when you want to print numbers 1 to 99. Or that you want to say Hello to 99 friends. In such a case, you can use loops in python.
Here, we will discuss 4 types of Python Loop:
- Python For Loop
- Python While Loop
- Python Loop Control Statements
- Nested For Loop in Python
Study all about “Loops” which consists of detailed information regarding For Loop, Python While Loop, Python Loop Control Statements, and Nested For Loop in Python with their subtypes, syntax, and examples.
5. Python constructors
Python Constructor in object-oriented programming with Python is a special kind of method/function we use to initialize instance members of that class. We can also use it to ensure we have enough resources. Whenever we create an object of that class, the constructor definition is the first to execute.
Let's learn more about python constructor.
6. Python exception handling
Python has many built-in exceptions that force your program to output an error when something in it goes wrong. When these exceptions occur, it causes the current process to stop and passes it to the calling process until it is handled. If not handled, our program will crash.
For example, if function A calls function B which in turn calls function C and an exception occurs in function C. If it is not handled in C, the exception passes to B and then to A.
If never handled, an error message is spit out and our program come to a sudden, unexpected halt
Let’s understand more about python exception handling.
7. Lambda Functions
Lambda functions are referred to as unknown functions. It fits for easy operations.
def say_hello():
return "hello"
#or
say_hello = lambda:"hello"
Read more about lambda functions.
8. Python regular expression
Python regular expression is a sequence of characters that defines a search pattern.
In Python Regex tutorial, you will learn the basics of regular expressions in Python.
9. Python functions
Python function in any programming language is a sequence of statements in a certain order, given a name.
Know about different types of functions in Python: Python built-in functions, Python recursion function, Python lambda function, and Python user-defined functions with their syntax and examples.
1O. Data Structures: List, Set, Dictionary
There are quite a few data structures available. The builtins data structures are lists, tuples, dictionaries, strings, sets, and frozen sets.
Lists are enclosed in brackets:
l = [1, 2, "a"]
Tuples are enclosed in parentheses:
t = (1, 2, "a")
Tuples are faster and consume less memory.
Dictionaries are built with curly brackets:
d = {"a":1, "b":2}
Learn more about data structures.
11. Python Decision Making Statements – Python If, If-else, Nested Statements
Sometimes, in a program, we may want to make a decision based on a condition. We know that an expression’s value can be True or False. We may want to do something only when a certain condition is true. For example, assume variables a and b. If a is greater, then we want to print “a is greater”. Otherwise, we want to print “b is greater”. For this, we use an if-statement. Also, operators come in handy when you want to join conditions to make a composite one.
Study in-depth about python decision making.
Learning doesn’t have any limits.
Learn python through the master guide.
So there are always endless topics that you will find about programming. But if we talk about some of the important concepts that you need to cover about python are covered in this article.
Thank You!
Happy- learning…….
Top comments (1)
Could be nice post if not the formatting or actually lack of it 🙄