How to use *args and **kwargs in Python

I have come to see that most new python programmers have a hard time figuring out the *args and **kwargs magic variables. So what are they ? First of all, let me tell you that it is not necessary to write *args or **kwargs. Only the * (asterisk) is necessary. You could have also written…

Read More

OOPs in Python

Object-oriented programming (OOP) is a programming paradigm based on the concept of objects which contains data or attributes and code or methods. Major oops concepts include Class, Object, Inheritance, Polymorphism, Data Abstraction, Encapsulation. Class Class is the user defined data type and it is defined using class keyword. It is a collection of similar type…

Read More

Python functions, Parameters, Arguments, args and kwargs

Python functions A function is a construct that helps us perform some action using a block of code (the body of the function), sometime based on input parameters. These functions can take different forms and can do a lot to allow your functional code base to be effective, To define a function, you use the…

Read More

List comprehensions, break-continue, exception handling in Python

As we have learned for loop to walk through a sequence, and do something with each item, at least read some value from it. There is a scenario, similar to what we saw with the last example in the for-loop introduction, that involves making a new list from the result of doing an operation on…

Read More

How to use if else, while and for loops in python?

The if and else clause are used to structure our code with checks for conditions. The if statement is followed by an expression that we use to express a condition, and delimiters the so-called if block. The block is executed if and only if the expression evaluates to True. Example 1: By the way, even…

Read More

Operations in Python

There are many type of different operations using operators in the language: Identity As we manipulate values (using variable), two values can have the same identity. This can be tested using special built-in function: id(). We use is as the identity comparison operator, and the result here shows that var and the var3 have the…

Read More

Data types in Python

Now let’s discover data types that we can use to manipulate more data and do more things, such as lists, sets, and dictionaries. Lists A list is a sequence of arbitrary objects. You remember we said that strings are a sequence of (text) characters, so some of the things we already seen about strings apply…

Read More

Python Basics

Let’s quickly explore the first tools and basic syntax rules for a beginner to start using Python. But before that, know that when needed, you can find documentation on the Python.org site and many online resources, including sites like StackOverflow. Printing things We use the print() function to print stuff in Python. This is essential…

Read More