Posts

Showing posts from March, 2023

Featured Post

Variables in Python: Python For Beginners

Image
Variables in Python: Python For Beginners Introduction This tutorial is for Python beginners who are confused with the usage of python variables. I will be first starting with the general definition of the term variable and then I will go on to explain it's usage, how it is created and the advantages of using python variables. What is a Variable A Variable is a container or placeholder for storing values while we carry out several tasks inside a Python function. A variable can store integers, float, string,list,tuple and even boolean. How Variables are Created & Declared In Python, we do not need any specific method or syntaxes to create variables. There is no need of explicitly declaring a variable. We just create a variable by assigning it a value with the 'equal to' sign and then a variable is created immediately! For Example: name = "Tracy Wills" age = 25 year = 2025 In the above examples, we created a variable by assigning it a value of "Tracy Wills...

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