Posts

Showing posts from March, 2023

Featured Post

Beginner's Guide On For Loop in Python

Image
  Beginner's Guide On For Loop in Python Introduction This post is for beginners who are trying to learn Python and they will find this step-by-step guide very easy to understand.  Here, I will be first introducing the concept of the 'for' loop in Python, and thereafter, I will proceed to explain the significance and methods of using this loop in your Python projects with several easy-to-understand examples and source code.   What is a 'for' loop A 'for' loop in Python is used to loop over a sequence and it is very useful when you perform tasks in your python functions. The 'for' loop could be used for looping or iterating over a list, tuple, set, dictionary or a string. We will see the examples below. During the phase of looping through a list for example, after creating the variable name to specify each item in the list, we will decide what is the action that is to be executed in the phase of this iteration whereby each and every item s...

A Simple Guide to Sets in Python

Image
A Simple Guide To Sets in Python Photo Credit : Photo by Markus Spiske from Pexels I NTRODUCTION Sets store multiple data collections in a single variable and the items have no particular order or index and they are also not mutable either, which is why, their items can appear in any order when we perform operations on them, since they are not indexed, so , we can not refer to them by their index position. A Set is represented by a pair of curly braces. A set does not permit duplicate items. HOW TO CREATE A SET  Below, in the code, you can understand, how a set is created. The variable myset is a set containing multiple items, that are string items , namely, 'cat', 'dog' and 'rabbit'. We use the curly braces to enclose the three items as shown below and you can use the print function to get the resultant set containing these items. mytuple = {cat","dog","rabbit"} print(myset)   ...

A Simple Guide to Python Tuples

Image
A Simple Guide To Python Tuples     picture credit : Person Holding an Orange and Blue Python Sticker by RealToughCandy What Are Tuples Tuples allow storage of multiple items using a single variable. Tuples are frequently used in Python for storing data and every programmer needs to know all about tuples in order to code efficiently in Python. Definition of Tuples Tuples could be considered as a collection containing multiple data items that are unchangeable and ordered and also  enclosed in round brackets.  Tuples are infact inbuilt data structures that store different types of data in one variable. Tuples use round parentheses to store data. How to create a Tuple Below, in the code, you can understand, how a tuple is created. The variable mytuple is a tuple containing multiple items, that are string items , namely, 'cat', 'dog' and 'rabbit'. We use the round brackets to enclose the three items as shown below and you can use the print function to get the result...