Found 26504 Articles for Server Side Programming

Python program to calculate square of a given number

Niharika Aitam
Updated on 19-Oct-2023 14:27:05

2K+ Views

Square is the defined as the multiplication of the number by itself. The square of a number n is given as n2. Mathematically we can implement square of the number as follows. $\mathrm{n^{2}=n*n}$ In the same way we can calculate the square of a given number by using python language too. There are few approaches in python to find the square of a number, let’s see them one by one. Using exponential operator (**) The exponential operator is the operator which is used to perform the exponent arithmetic operation. It is denoted with the symbol **. Syntax The ... Read More

Python program to calculate Date, Month and Year from Seconds

Niharika Aitam
Updated on 19-Oct-2023 14:23:07

954 Views

Generally, time is given in hours or minutes or seconds and from the given seconds, we can calculate the number of days, months and years. There are different modules and functions available in python such as datetime, time and divmod() which helps us to calculate the date month and year from seconds. Using Datatime module Datetime module offers classes to manipulate the dates and times. This module provides various functions and methods such as date, time, datetime, timedelta, minyear, maxyear, UTC etc. In the datetime method of datetime module we have the function utcfromtimestamp() which takes the seconds as ... Read More

Python program to calculate age in year

Niharika Aitam
Updated on 19-Oct-2023 14:20:56

16K+ Views

Generally, the age of a person is calculated by subtracting the birth year with the current year then the age of the person will be generated in years. In the same way we can calculate the age of a person by using the python modules datetime, dateutil and timedelta. General Calculation of Age in years Current year - Birth year Example In this example we are implementing the general way of calculating the age using pythn language by passing the current year and birth years as the inputs to created function age_calculator() then the total age will be generated ... Read More

Python program to calculate acceleration, final velocity, initial velocity and time

Niharika Aitam
Updated on 19-Oct-2023 14:17:19

2K+ Views

Acceleration, final velocity, initial velocity and time are the terms related to physical science which are widely used to study the motion and mechanics. Let’s see each one in detail. Acceleration Acceleration is the rate at which an object changes its velocity over the given time. It is denoted by a. Mathematically it is defined as the change in velocity divided by the change in time, the following is the formula. The unit of acceleration is meters per second $\mathrm{(m/s^2)}$ $\mathrm{a \:=\:(\Delta;\:vf − \Delta;vi)/\Delta;t}$ Where, $\mathrm{\Delta\:vi}$ is the Initial velocity $\mathrm{\Delta\:vf}$ is the Final velocity $\mathrm{\Delta\:t}$ is the ... Read More

Profiling in Python

Niharika Aitam
Updated on 19-Oct-2023 14:14:53

226 Views

In Python profiling is the measure of performance of different parts of a program to check and identify the areas of optimization and bottlenecks. We have many tools to perform profiling for the python code which includes built in modules, libraries and IDEs (Integrated development environments). There are different types of profiling of the python code, let’s see them one by one. Using Line profiling Line profiling is the technique used to measure the execution time of each individual line of the program. It helps us to identify which line is taking more execution time and to identify the tight ... Read More

Profile Application using Python Flask and MySQL

Niharika Aitam
Updated on 19-Oct-2023 14:12:47

356 Views

Flask is one of the web frameworks which provide libraries to build light weight web applications in python. It is a micro framework, developed by Armin Ronacher who runs an international group of python enthusiasts (POCCO). Flask works on WSGI toolkit and jinja2 template engines. For creating the profile application using python flask and MySQL we have to follow the below mentioned steps one by one. Step − 1 Install the virtual environment by executing the below mentioned command in the command prompt. pip install virtualenv Once the virtual environment is created we can create the new virtual environment into ... Read More

ProcessPoolExecutor Class in Python

Niharika Aitam
Updated on 19-Oct-2023 14:07:03

224 Views

The ProcessPoolExecutor class in python is part of the concurrent.futures module, is a high level interface for asynchronously executing functions using the processes and threads. The ProcessPoolExecutor allows us to execute the multiple functions in parallel using the multiple processes, which is particularly useful to CPU bound tasks that benefit in the parallelization process. Multiprocessing and Multithreading Before going to see about the ProcessPoolExecutor class we have to know about the Multiprocessing and Multithreading. Multiprocessing and Multithreading are the techniques used to achieve the parallelism process and they are different in the way they manage and create concurrent tasks. Multiprocessing ... Read More

Private Methods in Python

SaiKrishna Tavva
Updated on 17-Oct-2024 13:05:14

2K+ Views

In object-oriented programming,  private methods are functions that act as access modifier within a class designed only for internal use and not accessible from outside the class. The functionality of private methods is primarily meant for encapsulation which means that they are hidden to prevent unwanted modifications and misuse. Working of Private Methods In Python, the convention to denote private methods is "_". We just need to prefix the method name with a single underscore (_) or, double underscores (__). Single underscore(_) : To indicate that ... Read More

Priority Queue using Queue and Heapdict module in Python

Niharika Aitam
Updated on 19-Oct-2023 11:45:08

484 Views

The priority Queue is the abstract data type which is similar to the queue or stack, in which each element is attached with a priority. Here the priority determines the order of the elements to be dequeued from the queue and the higher priority elements are dequeued before the elements with the lower priority. The priority queues will be implemented using different data structures such as heaps, arrays or balanced trees. The most commonly used implementation is the heap, which is the binary tree based data structure having the value of each node greater than or equal to the values ... Read More

Golang program to implement a Trie data structure

Akhil Sharma
Updated on 18-Oct-2023 16:00:19

810 Views

A trie is a data structure like tree that is used to store and search a dynamic set of strings. It is useful while working with the data where keys share common prefix like dictionary words. Trie is different from the other retrieval data structures owing to its efficient string manipulation and retrieval properties. In this article we will learn to implement Trie data structure in Go programming language. Explanation The Trie, also known as a retrieval tree is a type of tree data structure that is commonly used for storing and managing collections of strings. It offers access, to ... Read More

Advertisements