Posts

Showing posts from March, 2023

Featured Post

How To Use While Loops In Python

Image
How To Use While Loops In Python Overview  This beginners Python guide will explain the steps for working with 'while' loops in Python for beginners. Introduction  The Python while loops help to execute a set of statements in Python functions,  as long as a particular specified condition is True. Let us understand the while loop with a simple python example exercise, of a while loop usage, where we are trying to count numbers from 1 to 10, with a condition of the number being less than 10. We create a variable called num, and initiate it with a initial value of 1 and we carry out iteration of this num variable, whereby, it is incrementing every time it loops, by incrementing by 1.  Code num = 1 while num < 10 :       print(num)       num += 1 # output   1 2 3 4 5 6 7   8  9 In the above case, we performed iteration of the while loop where every time the loop iterates, the num variable gets incremented by 1 a...

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...