Classes

Classes We explored OOP in an earlier blog and we touched on classes, so in this blog let’s explore classes in a greater length. Classes provide a way to package together data types and methods or functions, that are interrelated. Let’s consider the syntax of creating a class: class <class_name>: ….–code— class First_Class: variable1 =…

Map, Filter & Reduce

We learned about anonymous functions, but let’s explore 3 of Python’s most powerful anonymous functions and these are map(), filter(), and reduce(). These 3 enable us to approach programming with a functional paradigm {which is another way of saying we use functions}. Map We can use the map() function to use all of the provided…

Introduction to OOP

Introduction to OOP OOP stands for Object-Oriented Programming; it is a programming paradigm (or concept) that is aimed at making our program more readable and structured by grouping together all of the related variables and functions into a class. A class provides a blueprint of related variables and functions, and we create an object or…

Sets

Let us consider another type of data in Python which is called “Sets”. Like Lists, Tuples, & Dictionaries, Sets also provide us a way to store a collection of items but have their unique properties. Let’s look at an example of a Set: set_variable = {“Python”, “Dynamically Typed”, “Programming Language”} Accessing items of a Set…

Regular Expressions

Regular Expressions Regular Expressions (also well known as regex) allow us to search for a particular textual pattern. We use different kinds of symbols to create a regular expression, however, these symbols are universal for all programming languages. Using regex, some of the things we can ask Python to check is if the text has:…

Global Local and Nonlocal Variables

Variables are storehouses for values that we wish to use to achieve with programming. Defining variables also helps us to define the nature of operations for which we can use them. Global & Local Variables variable_1 = 5 # global variable def function_test(): variable_2 = 10 # local variable print(“variable_1 inside is”, variable_1) print(“variable_2 inside…

Modularity, Reusability, and Anonymous Functions

Modularity and Reusability Building on what we have learned so far, consider a comprehensive program that allows us to shop for fruits and vegetables. Here we have 3 Python files named “main.py”, “fruits.py”, and “vegetables.py” and all of these are stored in a separate folder called “Shopping_Module”. Here the main.py will have code that works…

Looping

Looping In the earlier blogs we used a “For Loop” to iterate (or explore) through items in a collection and in this blog, we will explore the two different kinds of looping mechanisms that we can use in Python. The two types of loops in Python are: For Loop While Loop NOTE: Don’t forget that…

Conditional Statment

Conditional Statements When we talked about operators, we talked about how manipulating logical expressions are the building block of programming. In this blog, we will explore conditional statements, which essentially are us telling the computer to do a certain computation or execute this block of code, if a particular condition is satisfied. If Statement The…

Tuples

Tuples Let’s look back to tuples and dive deeper into a topic we briefly brushed in an earlier blog. Consider the following: tuple_variable = (“Laptops”, “Mobiles”, “Game Consoles”, “Television”, “Smart Watches”) Accessing items in a Tuple An item within a tuple can be accessed the same way we would access a list’s item. print(tuple_variable[2])  #…