Posts

Showing posts from March, 2023

Featured Post

BUILD A TODO LIST IN PYTHON

Image
Build a TODO List in Python Overview The objective is to build a todo list to which we can add items, remove the added items, edit the items and even if required, delete out the entire list itself. We will learn here step by step, how to build the todo list with the above  CRUD (Create, Remove, Update/edit, and Delete ) features.  This is a CRUD list  app  that we are building as we can Create, Remove, Update items in the list and Delete the entire list itself. We will be using Python3 to build this Project. Importing os and time We import time to let the screen pause for a while before clearing  and we import os to clear the screen . Initializing the list We initialize the todo list with an empty list as there are not items added yet to the list and this is represented in the code aby using an empty square braces   toDoList = [] Defining the print list  The def keyword is used to define a function in python. In the below code, we define the function called printList(). When we define

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