Skip to main content

Posts

Showing posts with the label python basics

python3 list: creation, addition, deletion

 Introduction: Lists are one of the most fundamental data structures in python3.  In this article we are going to go through the basics and some of the advanced usage of lists in python and where should you use them and where you should not use them. what is list? List is a python data structure which is equivalent to a dynamic array in C++ or C. List is used to store normally homogeneous elements in python3; but pythons allow to store dissimilar elements in a list too. To say in summary, list is an ordered linear data structure. How to create a list? List can be created by using as simple as writing list = []; which initiates an empty list. Also, there is the list() builtin function in python which also creates a list. Empty lists can be created using both [] and list(); but it is known that [] is a bit faster method to initiate an empty list.  List can also be created with the elements to be put into it. i.e. you can start a list with the elements it is supposed t...

python3 dictionary: introduction, creation, addition and deletion

 Introduction:                      Photo by Dmitry Ratushny on Unsplash   We know that dictionary is one of the fundamental structures in python language. Dictionaries exist in the core of python structures; as the class objects are partially made by dictionary containing their information. I have been using python for more than 2 years now; and I have seen some good usage of dictionaries. Recently for a project, I solved a simple sounding yet, moderately complex problem using dictionaries heavily and revised some of the notions of pythonic writing of dictionaries along wise. This article will contain some of those understanding and best ways. What is dictionary? If you know what a dictionary is, then please skip to next section; but we will shortly define what is a dictionary and why would you like to use once. Dictionary is a unordered collection of values which are ind...