Latest Author Post

  • Top Python Interview Questions and Answers (PDF) in 2021
    We have prepared the most frequently asked Python Interview Questions and Answers that will help you to prepare for the interview questions on Python that an interviewer might ask you during your interview. In this list of Python Scripting interview questions, we have covered all commonly asked basic and advanced…
  • 15 Best Python Courses Online (Free & Paid) in 2021
    The following best online Python courses will help you to learn Python programming from home. Python is an object-oriented programming language created by Guido Rossum in 1989. It was designed for the rapid prototyping of complex applications. Python programming is widely used in AI (Artificial Intelligence), Natural Language Generation, Neural…
  • Python Tutorial PDF: Basics PDF for Beginners (Download Now)
    $20.20 $9.99 for today 4.5 (129 ratings) Key Highlights of Python Tutorial PDF 211+ pages eBook Designed for beginners Beautifully annotated screenshots You will get lifetime download access of this python tutorial PDF Python is an object-oriented programming language created by Guido Rossum in 1989. It is ideally designed for…
  • 11 Best Python Programming Books for Beginner (2021 Update)
    We are reader supported and may earn a commission when you buy through links on our site Python is the de facto language for data scientists, statisticians, machine learning experts, and web enthusiasts. There is a plethora of learning material available for Python and selection once could be difficult. Here…
  • BEST Python Certification Exam in 2021
    What is Python Certification? Python certification training courses help you to master the concepts. It also provides an opportunity for you to gain in-depth expertise in writing Python programs and use related packages like SciPy, Pandas, NumPy, Lambda function, and Web scraping libraries. Some advance level Python course also helps…
  • 10 BEST Python IDE | Python Editors for Windows, Linux & Mac
    Python code editors are designed for the developers to code and debug program easily. Using these Python IDEs(Integrated Development Environment), you can manage a large codebase and achieve quick deployment. Developers can use these editors to create desktop or web application. The Python IDEs can also be used by DevOps…
  • 15 Best Web Scraping Tools for Data Extraction in 2021
    Web scraping tools are specially developed software for extracting useful information from the websites. These tools are helpful for anyone who is looking to collect some form of data from the Internet. Here, is a curated list of Top Web Scraping Tools. This list includes commercial as well as open-source…
  • Import module in Python with Examples
    What are the modules in Python? A module is a file with python code. The code can be in the form of variables, functions, or class defined. The filename becomes the module name. For example, if your filename is guru99.py, the module name will be guru99. With module functionality, you…
  • Multithreading in Python with Global Interpreter Lock (GIL) Example
    The python programming language allows you to use multiprocessing or multithreading.In this tutorial, you will learn how to write multithreaded applications in Python. What is a Thread? A thread is a unit of exection on concurrent programming. Multithreading is a technique which allows a CPU to execute many tasks of…
  • PyQt5 Tutorial: Design GUI using PyQt in Python with Examples
    What is PyQt? PyQt is a python binding of the open-source widget-toolkit Qt, which also functions as a cross-platform application development framework. Qt is a popular C++ framework for writing GUI applications for all major desktop, mobile, and embedded platforms (supports Linux, Windows, MacOS, Android, iOS, Raspberry Pi, and more)….
  • Python XML Parser Tutorial: Read xml file example(Minidom, ElementTree)
    What is XML? XML stands for eXtensible Markup Language. It was designed to store and transport small to medium amounts of data and is widely used for sharing structured information. Python enables you to parse and modify XML document. In order to parse XML document you need to have the…
  • Python Internet Access using Urllib.Request and urlopen()
    What is urllib? urllib is a Python module that can be used for opening URLs. It defines functions and classes to help in URL actions. With Python you can also access and retrieve data from the internet like XML, HTML, JSON, etc. You can also use Python to work with…
  • Django Tutorial for Beginners
    Before learning Django, let’s understand: What is a Web Framework? A web framework is a code library which helps you to build a flexible, scalable, and maintainable; dynamic website, web app, and web services. Different web frameworks are Zend for PHP, Ruby on Rails for Ruby, etc. What is Django?…
  • PyTest Tutorial: What is, How to Install, Framework, Assertions
    What is PyTest? PyTest is a testing framework that allows users to write test codes using Python programming language. It helps you to write simple and scalable test cases for databases, APIs, or UI. PyTest is mainly used for writing tests for APIs. It helps to write tests from simple…
  • Python CALENDAR Tutorial with Example
    Calendar module in Python has the calendar class that allows the calculations for various task based on date, month, and year. On top of it, the TextCalendar and HTMLCalendar class in Python allows you to edit the calendar and use as per your requirement. Let see what we can do…
  • Python DateTime, TimeDelta, Strftime(Format) with Examples
    In Python, date, time and datetime classes provides a number of function to deal with dates, times and time intervals. Date and datetime in Python are the objects, so when you manipulate them, you are actually manipulating objects and not string or timestamps. Whenever you manipulate dates or time, you…
  • Python RegEx: re.match(), re.search(), re.findall() with Example
    What is Regular Expression in Python? A Regular Expression (RE) in a programming language is a special text string used for describing a search pattern. It is extremely useful for extracting information from text such as code, files, log, spreadsheets or even documents. While using the Python regular expression the…
  • Python List index() with Example
    A list is a container that stores items of different data types (ints, floats, Boolean, strings, etc.) in an ordered sequence. It is an important data structure that is in-built in Python. The data is written inside square brackets ([]), and the values are separated by comma(,). The items inside…
  • Remove element from a Python LIST [clear, pop, remove, del]
    Python List data-type helps you to store items of different data types in an ordered sequence. The data is written inside square brackets ([]), and the values are separated by comma(,). In Python, there are many methods available on the list data type that help you remove an element from…
  • Python remove Duplicates from a List
    A list is a container that contains different Python objects, which could be integers, words, values, etc. It is the equivalent of an array in other programming languages. So here will go through different ways in which we can remove duplicates from a given list. In this tutorial, you will…
  • Python List count() with EXAMPLES
    Python count The count() is a built-in function in Python. It will return the total count of a given element in a list. The count() function is used to count elements on a list as well as a string. In this Python tutorial, you will learn: Python count Python List…
  • Python Average: How to Find AVERAGE of a List in Python
    Python Average The Python Average function is used to find the average of given numbers in a list. The formula to calculate average in Python is done by calculating the sum of the numbers in the list divided by the count of numbers in the list. The Python average of…
  • Python List: Comprehension, Apend, Sort, Length, Reverse EXAMPLES
    What is a Python List? A list is exactly what it sounds like, a container that contains different Python objects, which could be integers, words, values, etc. It is the equivalent of an array in other programming languages. It is represented by square brackets (and this is one of the…
  • Python vs JAVA vs PHP vs PERL vs Ruby vs JavaScript vs C++ vs TCL
    Python is one of the most popular programming languages. Currently, each of the following six languages are being used by programmers for developing both desktop and web applications. That is why, it is important for programmers to compare Python with JAVA, RUBY, PHP, TCL and Perl to pick the right…
  • Flask vs Django: What’s the Difference Between Flask & Django?
    In this tutorial of difference between Flask vs Django, we will discuss the key differences between Django and Flask. But before discussing the difference between Django vs Flask, let’s first learn “What is Django?” and “What is Flask?”. Let’s start with Flask: What is Flask? Flask is an micro framework…
  • Python vs C++: What’s the Difference?
    What is C++? C++ is widely used in general-purpose programming languages. The language allows you to encapsulates high and low-level language features. So, it is seen as an intermediate-level language. It also used to develop complex systems where the hardware level coding requires. In this tutorial, you will learn: What…
  • Python 2 vs Python 3: What’s the Difference Between Python 2.x and Python 3.x?
    What is Python 2? Python 2 made code development process easier than earlier versions. It implemented technical details of Python Enhancement Proposal (PEP). Python 2.7 (last version in 2.x ) is no longer under development and in 2020 will be discontinued. In this tutorial, you will learn, What is Python…
  • Python vs Ruby: What’s the Difference?
    In this tutorial of difference between Ruby and Python, we will discuss the key differences between Ruby vs Python. But before jumping into the difference, let us first look at them individually like “What is Python?” and “What is Ruby?”. Let’s start with Python: What is Python? Python is a…
  • Python vs JavaScript: Difference Between Python and JS
    In this tutorial of difference between Python and JavaScript, we will discuss the key differences between Python vs JavaScript. But before discussing the difference, let us first look at them individually like “What is JavaScript?” and “What is Python?”. Let’s start with JavaScript: What is JavaScript? JavaScript is a scripting…
  • Python vs Go: What’s the Difference?
    What Is Golang? Go is an open-source programming language developed by Google. It is a statically-typed compiled language. This language support concurrent programming and also allows running multiple processes simultaneously. This is achieved using channels, goroutines, etc. Go has garbage collection, which itself does the memory management and allows the…
  • Python Vs PHP: What’s the Difference Between Python and PHP?
    What is Python? Python is a high-level object-oriented programming language. It has built-in data structures, combined with dynamic typing & binding, which makes it an ideal choice for rapid application development. Python also offers support for modules and packages, which allows system modularity and code reuse. It is one of…
  • Python Matrix: Transpose, Multiplication, NumPy Arrays Examples
    What is Python Matrix? A Python matrix is a specialized two-dimensional rectangular array of data stored in rows and columns. The data in a matrix can be numbers, strings, expressions, symbols, etc. Matrix is one of the important data structures that can be used in mathematical and scientific calculations. In…
  • Facebook Login using Python: FB Login Example
    In order to log into Facebook using Python, you need to use Selenium (a web automation tool). Selenium can automate and control a browser and click, fill text, submit buttons that appear on various websites. To log in to Facebook, we will use a Python Script that drives Selenium. The…
  • PyUnit Tutorial: Python Unit Testing Framework (with Example)
    What is Unit Testing? Unit Testing in Python is done to identify bugs early in the development stage of the application when bugs are less recurrent and less expensive to fix. A unit test is a scripted code level test designed in Python to verify a small “unit” of functionality….
  • Python with MySQL Connectivity: Connector, Create Database, Table, Insert [Examples]
    In order to use MySQL connectivity with Python, you must have some knowledge of SQL Before diving deep, let’s understand What is MySQL? MySQL is an Open-Source database and one of the best type of RDBMS (Relational Database Management System). Co-founder of MySQLdb is Michael Widenius’s, and also MySQL name…
  • Python JSON: Encode(dumps), Decode(loads) & Read JSON File
    What is JSON in Python? JSON in Python is a standard format inspired by JavaScript for data exchange and data transfer as text format over a network. Generally, JSON is in string or text format. It can be used by APIs and databases, and it represents objects as name/value pairs….
  • Reading and Writing CSV Files in Python using Module & Pandas
    What is a CSV file? A CSV file is a simple type of plain text file which uses a specific structure to arrange tabular data. The standard format of a CSV file is defined by rows and columns data where a newline terminates each row to begin the next row,…
  • Python Dictionary Append: How to Add Key/Value Pair
    Dictionary is one of the important data types available in Python. The data in a dictionary is stored as a key/value pair. It is separated by a colon(:), and the key/value pair is separated by comma(,). The keys in a dictionary are unique and can be a string, integer, tuple,…
  • SciPy in Python Tutorial: What is | Library & Functions Examples
    SciPy in Python SciPy in Python is an open-source library used for solving mathematical, scientific, engineering, and technical problems. It allows users to manipulate the data and visualize the data using a wide range of high-level Python commands. SciPy is built on the Python NumPy extention. SciPy is also pronounced…
  • Python readline() Method with Examples
    What is Python readline? Python readline() is a file method that helps to read one complete line from the given file. It has a trailing newline (“\n”) at the end of the string returned. You can also make use of the size parameter to get a specific length of the…
  • Python Exception Handling: Try, Catch, Finally
    What is an Exception in Python? An exception is an error which happens at the time of execution of a program. However, while running a program, Python generates an exception that should be handled to avoid your program to crash. In Python language, exceptions trigger automatically on errors, or they…
  • Python ZIP file with Example

    Python allows you to quickly create zip/tar archives.

    Following command will zip entire directory

    shutil.make_archive(output_filename, 'zip', dir_name)

    Following command gives you control on the files you want to archive

    ZipFile.write(filename)

    Here are the steps to create Zip File in Python

    Step 1) To create an archive file from Python, make sure you have your import statement correct and in order. Here the import statement for the archive is from shutil import make_archive

    Python OS Module, Shell Script Commands

    Code Explanation

    • Import make_archive class from module shutil
    • Use the split function to split out the directory and the file name from the path to the location of the text file (guru99)
    • Then we call the module “shutil.make_archive(“guru99 archive, “zip”, root_dir)” to create archive file, which will be in zip format
    • After then we pass in the root directory of things we want to be zipped up. So everything in the directory will be zipped
    • When you run the code, you can see the archive zip file is created on the right side of the panel.

    Step 2) Once your archive file is made, you can right-click on the file and select the O.S, and it will show your archive files in it as shown below

    Python OS Module, Shell Script Commands

    Now your archive.zip file will appear on your O.S (Windows Explorer)

    Python OS Module, Shell Script Commands

    Step 3) When you double-click on the file, you will see the list all the files in there.

    Python OS Module, Shell Script Commands

    Step 4) In Python we can have more control over archive since we can define which specific file to include under archive. In our case, we will include two files under archive “guru99.txt” and “guru99.txt.bak”.

    Python OS Module, Shell Script Commands

    Code Explanation

    • Import Zipfile class from zip file Python module. This module gives full control over creating zip files
    • We create a new Zipfile with name ( “testguru99.zip, “w”)
    • Creating a new Zipfile class, requires to pass in permission because it’s a file, so you need to write information into the file as newzip
    • We used variable “newzip” to refer to the zip file we created
    • Using the write function on the “newzip” variable, we add the files “guru99.txt” and “guru99.txt.bak” to the archive

    When you execute the code you can see the file is created on the right side of the panel with name “guru99.zip”

    Note: Here we don’t give any command to “close” the file like “newzip.close” because we use “With” scope lock, so when program falls outside of this scope the file will be cleaned up and is closed automatically.

    Step 5) When you -> right click on file (testguru99.zip) and -> select your O.S (Windows Explorer), it will show the archive files in the folder as shown below.

    Python OS Module, Shell Script Commands

    When you double click on file “testguru99.zip”, it will open another window, and this will show the files included in it.

    Python OS Module, Shell Script Commands

    Here is the complete code

  • Python Rename File and Directory using os.rename()
    Python Rename File Python rename() file is a method used to rename a file or a directory in Python programming. The Python rename() file method can be declared by passing two arguments named src (Source) and dst (Destination). Syntax This is the syntax for os.rename() method os.rename(src, dst) Parameters src:…
  • Python COPY File using shutil.copy(), shutil.copystat()
    Python Copy File Methods Python provides in-built functions for easily copying files using the Operating System Shell utilities. Following command is used to Copy File shutil.copy(src,dst) Following command is used to Copy File with MetaData Information shutil.copystat(src,dst) Here are the steps to copy file in Python Step 1) Before, we…
  • Python Check If File Exists | How to Check If a Directory Exists in Python
    Python exists() Python exists() method is used to check whether specific file or directory exists or not. It is also used to check if a path refers to any open file descriptor or not. It returns boolean value true if file exists and returns false otherwise. It is used with…
  • Python Arrays: Create, Reverse, Pop with Python Array Examples
    What is Python Array? A Python Array is a collection of common type of data structures having elements with same data type. It is used to store collections of data. In Python programming, an arrays are handled by the “array” module. If you create arrays using the array module, elements…
  • Python File Handling: How to Create Text File, Read, Write, Open, Append Files in Python
    In Python, there is no need for importing external library to read and write files. Python provides an inbuilt function for creating, writing, and reading files. In this file handling in Python tutorial, we will learn: How to Open a Text File in Python How to Create a Text File…
  • Python New Line: How to Print WITHOUT Newline in Python
    Python print() built-in function is used to print the given content inside the command prompt. The default functionality of Python print is that it adds a newline character at the end. In this Python tutorial, you will learn: Working of Normal print() function How to print without a newline in…
  • type() and isinstance() in Python with Examples
    What is type() in Python? Python has a built-in function called type() that helps you find the class type of the variable given as input. For example, if the input is a string, you will get the output as <class ‘str’>, for the list, it will be <class ‘list’>, etc….
  • Python time.sleep(): Add Delay to Your Code (Example)
    What is Python Sleep? Python sleep() is a function used to delay the execution of code for the number of seconds given as input to sleep(). The sleep() command is a part of the time module. You can use the sleep() function to temporarily halt the execution of your code….
  • Enumerate() Function in Python: Loop, Tuple, String (Example)
    What is Python Enumerate? Python Enumerate() is a buit-in function available with the Python library. It takes the given input as a collection or tuples and returns it as an enumerate object. The Python Enumerate() command adds a counter to each item of the iterable object and returns an enumerate…
  • Python Counter in Collections with Example
    What is Python Counter? Python Counter is a container that will hold the count of each of the elements present in the container. The counter is a sub-class available inside the dictionary class. The counter is a sub-class available inside the dictionary class. Using the Python Counter tool, you can…
  • Python Queue: FIFO, LIFO Example
    What is Python Queue? A queue is a container that holds data. The data that is entered first will be removed first, and hence a queue is also called “First in First Out” (FIFO). The queue has two ends front and rear. The items are entered from the rear and…
  • Yield in Python Tutorial: Generator & Yield vs Return Example
    What is Python yield? The yield keyword in python works like a return with the only difference is that instead of returning a value, it gives back a generator object to the caller. When a function is called and the thread of execution finds a yield keyword in the function,…
  • Python Timeit() with Examples
    What is Python Timeit()? Python timeit() is a method in Python library to measure the execution time taken by the given code snippet. The Python library runs the code statement 1 million times and provides the minimum time taken from the given set of code snippets. Python timeit() is a…
  • Python map() function with EXAMPLES
    Python map() applies a function on all the items of an iterator given as input. An iterator, for example, can be a list, a tuple, a set, a dictionary, a string, and it returns an iterable map object. Python map() is a built-in function. In this tutorial, you will learn:…
  • Python round() function with EXAMPLES
    Round() Round() is a built-in function available with python. It will return you a float number that will be rounded to the decimal places which are given as input. If the decimal places to be rounded are not specified, it is considered as 0, and it will round to the…
  • Python range() Function: Float, List, For loop Examples
    What is Python Range? Python range() is a built-in function available with Python from Python(3.x), and it gives a sequence of numbers based on the start and stop index given. In case the start index is not given, the index is considered as 0, and it will increment the value…
  • Python abs() Function: Absolute Value Examples
    Python abs() Python abs() is a built-in function available with the standard library of python. It returns the absolute value for the given number. Absolute value of a number is the value without considering its sign. The number can be integer, floating point number or complex number. If the given…
  • Python Lambda Functions with EXAMPLES
    What is Lambda Function in Python? A Lambda Function in Python programming is an anonymous function or a function having no name. It is a small and restricted function having no more than one line. Just like a normal function, a Lambda function can have multiple arguments with one expression….
  • Python Functions Examples: Call, Indentation, Arguments & Return Values
    What is Function in Python? A Function in Python is a piece of code which runs when it is referenced. It is used to utilize the code in more than one place in a program. It is also called method or procedure. Python provides many inbuilt functions like print(), input(),…
  • Python Main Function & Method Example: Understand __main__
    What is Python Main Function? Python main function is a starting point of any program. When the program is run, the python interpreter runs the code sequentially. Main function is executed only when it is run as a Python program. It will not run the main function if it imported…
  • Python String find() Method with Examples
    What is Python String find()? Python String find() is a function available in Python library to find the index of the first occurrence of a substring from the given string. The string find() function will return -1 instead of throwing an exception, if the specified substring is not present in…
  • Python string length | len() method Example
    len() is a built-in function in python. You can use the len() to get the length of the given string, array, list, tuple, dictionary, etc. You can use len function to optimize the performance of the program. The number of elements stored in the object is never calculated, so len…
  • Python String format() Explain with EXAMPLES
    What is Python String format()? Python String format() is a function used to replace, substitute, or convert the string with placeholders with valid values in the final string. It is a built-in function of the Python string class, which returns the formatted string as an output. The placeholders inside the…
  • Python String count() with EXAMPLES
    Python count The count() is a built-in function in Python. It will return the total count of a given element in a string. The counting begins from the start of the string till the end. It is also possible to specify the start and end index from where you want…
  • Python String strip() Function with EXAMPLE
    What is Python strip()? Python strip() function is a part of built-in functions available in the Python library. The strip() method removes given characters from start and end of the original string. By default, strip() function removes white spaces from start and end of the string and returns the same…
  • Python Strings: Replace, Join, Split, Reverse, Uppercase & Lowercase
    In Python everything is object and string are an object too. Python string can be created simply by enclosing characters in the double quote. For example: var = “Hello World!” In this tutorial, we will learn – Accessing Values in Strings Various String Operators Some more examples Python String replace()…
  • Python OOPs: Class, Object, Inheritance and Constructor with Example
    OOPs in Python OOPs in Python is a programming approach that focuses on using objects and classes as same as other general programming languages. The objects can be any real-world entities. Python allows developers to develop applications using the OOPs approach with the major focus on code reusability. It is…
  • Python break, continue, pass statements with Examples
    The concept of loops is available in almost all programming languages. Python loops help to iterate over a list, tuple, string, dictionary, and a set. There are two types of loop supported in Python “for” and “while”. The block of code is executed multiple times inside the loop until the…
  • Python TUPLE – Pack, Unpack, Compare, Slicing, Delete, Key
    What is Tuple Matching in Python? Tuple Matching in Python is a method of grouping the tuples by matching the second element in the tuples. It is achieved by using a dictionary by checking the second element in each tuple in python programming. However, we can make new tuples by…
  • Python For & While Loops: Enumerate, Break, Continue Statement
    What is Loop? Loops can execute a block of code number of times until a certain condition is met. Their usage is fairly common in programming. Unlike other programming language that have For Loop, while loop, dowhile, etc. What is For Loop? For loop is used to iterate over elements…
  • How to Install Python on Windows [Pycharm IDE]
    PyCharm is a cross-platform editor developed by JetBrains. Pycharm provides all the tools you need for productive Python development. Below are the detailed steps for installing Python and PyCharm How to Install Python IDE Below is a step by step process on how to download and install Python on Windows:…
  • Python Tutorial for Beginners: Learn Programming Basics [PDF]
    Python Tutorial Summary In this Python tutorial for beginners, you will learn Python programming basics and advanced concepts. This Python course contains all the Python basics from installation to advanced stuff like Python data science. This Python programming tutorial helps you to learn Python free with Python notes and Python…
  • Hello World: Create your First Python Program
    In the last tutorial, we completed our Python installation and setup. It’s time to create your first program. Creating First Program Step 1) Open PyCharm Editor. You can see the introductory screen for PyCharm. To create a new project, click on “Create New Project”. Step 2) You will need to…
  • Python Print() Statement: How to Print with Examples
    In this tutorial, you will learn- How to Print a simple String in Python? How to print blank lines Print end command Python print() function The print() function in Python is used to print a specified message on the screen. The print command in Python prints strings or objects which…
  • Python Dictionary(Dict): Update, Cmp, Len, Sort, Copy, Items, str Example
    What is a Dictionary in Python? A Dictionary in Python is the unordered and changeable collection of data values that holds key-value pairs. Each key-value pair in the dictionary maps the key to its associated value making it more optimized. A Dictionary in python is declared by enclosing a comma-separated…
  • Python Conditional Statements: IF…Else, ELIF & Switch Case
    What are Conditional Statements in Python? Conditional Statement in Python perform different computations or actions depending on whether a specific Boolean constraint evaluates to true or false. Conditional statements are handled by IF statements in Python. In this tutorial, we will see how to apply conditional statements in Python. What…
  • Python Operators: Arithmetic, Logical, Comparison, Assignment, Bitwise & Precedence
    What are Logical Operators in Python? Logical Operators in Python are used to perform logical operations on the values of variables. The value is either true or false. We can figure out the conditions by the result of the truth values. There are mainly three types of logical operators in…
  • Python Variables: How to Define/Declare String Variable Types
    What is a Variable in Python? A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing. Python Variable Types Every value in Python has a datatype. Different data types in Python are Numbers,…