Singleton design pattern categorized under creational design patterns. It is one of the most simple design pattern in terms of the modelling. In this article we are going to take a deeper look into the usage of the Singleton pattern.

  • Singleton controls object creation by limiting the number of objects to only one object. When an instance is wanted to be created from any class, if there is no instance created before, a new one is created. If it has been created before, the existing instance is used.
  • The Singleton design pattern ensures a class has only one instance and…

Why we use a list comprehension?

Photo by Claire Satera on Unsplash

There are some different ways you can create a list in python. List comprehension offers a shorter syntax when you want to create a new list. You could rewrite the for loop from the example below in just a single line of code:

Let’s do the same example with the help from list comprehension:
  • What is the file operations?
  • Some useful functions for file operations such as open() for opening a file, read() for reading from it, and write() writing into it and various file methods.

Python, a file operation takes place in the following order:

  • Open a file
  • Read or write
  • Close the file

We will use a open function for opening a file.
This function creates a new file or opens the existing file, according to the parameters we have written.

file=open(“fileName.txt”, “mode”)

When we are done with performing operations on the file, we need to close the file.


We can…

A Guide To Creating Global and Local Variables in Python

Photo by Sean Lim on Unsplash

In Python, each variable, function, and class has a scope. Functions creates a new scope when they are defined and Python defines each variable in a namespace. Thus, we need to learn how to handle variables defined inside and outside the function.

The values ​​defined in the function are called local variables. These values ​​disappear after the function runs. For this reason, local variables cannot be accessed from the desired location of the program.

Photo by Christina Morillo from Pexels

A list is an ordered sequence of items. List elements can be of any type such as strings or numbers while arrays do not allow this. Sequences are of specific type and size so this is the difference of lists from array. We can create an empty list, string list or any type of list as shown in the example below.

In today’s conditions, we provide data exchange over the internet for many transactions. All these transactions are carried out with our personal and credit card information. Therefore, the seamless transportation of data and privacy has become our most significant requirement. As a result of this requirement, various encryption and keying algorithms have been developed in order to send and receive data securely. There are two types of encryption algorithms according to the characteristics of the key used for encryption.

1- Symmetric Encryption


Computer Engineering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store