Essential tips & tricks for better programming

Image Created By Author Using Canva.com

1. Permutation with itertools:

In this program, we import the built-in module called itertools. With itertools, you can find all the permutations of the given string. In itertools there are numerous methods, you can try a combination and other methods.

2. One-Line Condition Expression:

This conditional expression was added to Python 2.5 version. This can be used with A if condition else B syntax. First, the condition is evaluated and returns based on the boolean value of the condition. If it is true it returns A or else if it is false it returns B.

3. Reverse a string:

In this program, we use an extended slice to reverse the…


A schedule and resources to cover python basics

Photo by Alejandro Escamilla on Unsplash

Python is one of the popular programming languages. Mastering Python basics is crucial. Python has an easy and simple code style, which makes it easy to learn. It is also the language that is used in developing many media networks like Instagram, Amazon, Uber, Netflix, and many more.

In this article, let us try to learn the basics of python in 10 days. This article is written assuming you have some programming knowledge.

Day 1- Installation and First program:

First, you need an IDE for running your python script. If you already don’t have one, Pycharm is one of the best IDE. The community version is…


Must know functions in Python explained with code

Photo by Christopher Gower on Unsplash

In this article, five important functions are explained in detail with code. These functions are simple yet the most powerful function in Python. Python has many libraries and built-in functions. Understanding these functions and using them properly helps with efficient programming.

1. Lambda Function:

One of the most powerful functions in Python also known as the anonymous function. It is known as anonymous because we can instantiate and declare a function without a name. If you have a single operation to be executed, the lambda function is extremely useful instead of declaring a traditional function. …


Creating, merging, locking, unlocking, and watermarking explained with code

Image Created By Author Using Canva.com

PDF files are extensively used in many fields and learning to handle PDF files is important. In this article, we try to do different operations on the PDF file like locking, unlocking, merging, creating, and adding watermark with python script.

1.Locking or encrypting a PDF file:

A program to lock the PDF file with the given password with Python.

Some PDF files with important information need to be protected. Let us try to do this with a python script. Install the python package used in this program with pip install PyPDF2 syntax.

Note: Two methods PdfFileReader and PdfFileWriter are used, to read and write a…


Python programs explained in detail

Photo by James Harrison on Unsplash

Python programs have many modules and packages, which helps with efficient programming. Understanding these modules and proper usage is important. In this article, a few interesting modules and packages are used for programming.

1. Python Fake Information Generator

Create a program to generate fake data like name, email, or detailed fake profile with all the information about a person.

Faker is a python package, which can be installed by using pip install Faker in the terminal. Each time you run this program faker generator, it will result in different random data.

Output:


Three types of string formatting in Python explained in detail with examples

Photo by Hitesh Choudhary on Unsplash

Implementing string formatting helps with control over the console while printing. It reduces the junk code and makes it much easier to read the code. In this article, let us understand three commonly used string formatting methods.

C - style string formatting method:

If you have ever worked with c programming, then this should sound familiar. This uses a % operator to format the string in the program. Commonly used string formatting placeholders are:

  • %s - It acts as a place holder for string or other objects
  • %d - It acts as a placeholder for integers
  • %f - It acts as a placeholder for floating-point numbers


Methods explained with examples

Photo by Mr Cup / Fabien Barral on Unsplash

Extensive markup language supports the hierarchical representation of the data. Understanding parsing and modification of an XML file are important for web scraping. Searching, modification, and processing of the XML document are explained in this article.

For better understanding, let us consider an example XML file:

Parsing of the XML file:

To parse an XML file first import ElementTree package for parsing an XML file. ET is a commonly used alias for the ElementTree. Parsing is a process where the interface reads the XML documents. After reading the XML file, the interface can perform certain functions like searching, building, modifications.

Accessing each node’s text in the XML file:

While the XML…


Helps understand random module better

Photo by Mick Haupt on Unsplash

Python comes with a variety of random modules to generate a random number. Unpredictability is necessary for most of the computing process. Python uses a pseudo-random number generator. A complete understanding of modules is the key to problem-solving.

1. How to print directories all the methods in the random module?

Random has many inbuilt modules for efficient programming. By using the dir command, you will be able to print all the methods in the random module.


Photo by Jakob Owens on Unsplash

The Internet, phones, camera, and social networks continue to thrive and become an essential part of our lives. Logically, you can find thousands of social media uses. Among them, I use Instagram as a diary to keep all my photos to ensure the fond memories are not lost.

I have two profiles, one is for actual socializing, and the other is for keeping my photos. My diary account has no followers, and its sole purpose is to keep my data safe, organized, and caption to represent that moment.

Haven’t you noticed losing some photos and data somehow in the long…


Simple Programs to understand data structure better

Photo by Christopher Gower on Unsplash

Data structures are used to store data more efficiently. In python, there are four kinds of iterable objects which are used for the collection of data. The four data structures in python are Lists, Tuples, Sets, Dictionary. These data structures are used from simple programs to complex programs. Proper understanding and usage of this data structure help run efficiently.

Swathi Arun

Art | Travel | Engineer | Writer I am a programmer who loves to write about my traveling experience.

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