Python 3 – Hello World

Python is a high-level and Interpreter based language. Python was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code. So, without any ado, let’s start writing our first HELLO WORLD program in Python. Output: Hello World Congratulations on writing your First Python Code. Now, let’s… Continue reading Python 3 – Hello World

Python Urllib Module

Python Urllib Module Urllib package is the URL handling module for python. It is used to fetch URLs (Uniform Resource Locators). It uses the urlopen function and is able to fetch URLs using a variety of different protocols. Urllib is a package that collects several modules for working with URLs, such as:   urllib.request for opening and… Continue reading Python Urllib Module

How to calculate dot product of two vectors in Python?

How to calculate dot product of two vectors in Python? In mathematics, the dot product or also known as the scalar product is an algebraic operation that takes two equal-length sequences of numbers and returns a single number. Let us given two vectors A and B, and we have to find the dot product of two vectors. Given that,     and, Where,… Continue reading How to calculate dot product of two vectors in Python?

Difference between Pandas VS NumPy

Difference between Pandas VS NumPy Pandas is an open-source, BSD-licensed library written in Python Language. Pandas provide high performance, fast, easy to use data structures and data analysis tools for manipulating numeric data and time series. Pandas is built on the numpy library and written in languages like Python, Cython, and C. In pandas, we can import data from various file formats like JSON, SQL, Microsoft Excel, etc. Example:… Continue reading Difference between Pandas VS NumPy

Pretty Print JSON in Python

Pretty Print JSON in Python JSON is a javascript notation of storing and fetching the data. Data is usually stored in JSON, XML or in some other database. It is a complete language-independent text format. To work with JSON data, Python has a built-in package called json. Pretty Print JSON Whenever data is dumped into Dictionary using… Continue reading Pretty Print JSON in Python

Python program to find the sum of all items in a dictionary

Python program to find the sum of all items in a dictionary Given a dictionary in Python, write a Python program to find the sum of all Items in the dictionary. Examples: Input : {‘a’: 100, ‘b’:200, ‘c’:300} Output : 600 Input : {‘x’: 25, ‘y’:18, ‘z’:45} Output : 88     Approach #1 : Using… Continue reading Python program to find the sum of all items in a dictionary

Python strip() method

Python String | strip() The strip() method in-built function of Python is used to remove all the leading and trailing spaces from a string. Syntax :string.strip([chars])   Parameter: chars(optional): Character or a set of characters, that needs to be removed from the string. Returns: A copy of the string with both leading and trailing characters stripped. Using strip() method:… Continue reading Python strip() method