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]) #…
Lists
Lists in Python We were introduced to the list data type in an earlier blog, and in this blog, we will explore the different ways to use a list. Consider the following example: list_variable = [“Python”, “Dynamically Typed”, “Programming Language”] Accessing items in a List To select an item from the list you simply add…
String
Strings in Python In the previous blog Data Types, we explored Strings in Python, and in this blog let’s dig a bit deeper into strings and what we can do with them. A string in Python is an array (or list) of characters, and in Python, a single character is still considered as a string…
Data Types
Data Types We explored the numeric data types when we talked about numbers in Python. However, there is a whole range of data types that we can use in Python, and in this blog, we’ll explore some of the most commonly used data types. What exactly is a data type? It refers to the different…