Found 10769 Articles for Python

Python Program to Find Cube of a Number

AYUSH MISHRA
Updated on 31-Jan-2025 19:50:03

395 Views

The Cube of a number is a simple mathematical operation where a number is multiplied by itself three times. In Python, there are multiple ways to find the cube of a number. In this article, we are going to discuss various approaches to calculating the cube of a number in Python. How to find cube of a number? The formula for finding the cube of a given number N is: Cube = N × N × N or N3 Example 1 Input: 5 Output: 125 Explanation: The cube of ... Read More

Python Program for Fahrenheit to Celsius conversion

AYUSH MISHRA
Updated on 21-Jan-2025 18:46:44

2K+ Views

Problem Description In this problem, we are given a temperature value in Fahrenheit and we have to convert it to Celsius. This conversion is used in various real-world applications such as weather applications, scientific calculations, and data analysis. In this article, we are going to discuss, how we can convert Fahrenheit temperature to Celsius temperature in Python. Formula to Convert Fahrenheit to Celsius The formula for converting Fahrenheit to Celsius is: Celsius = (Fahrenheit - 32) / 1.8 Example 1 Input: Fahrenheit = 98.6 Output: Celsius = 37°C Explanation: The ... Read More

Python program to find volume of capsule

AYUSH MISHRA
Updated on 15-Jan-2025 18:53:14

4K+ Views

What is Capsule and Its Volume? A capsule is a three-dimensional geometric figure that consists of a cylindrical body with hemispherical ends on both sides. The volume of a capsule can be calculated by adding the volume of the cylindrical part and the volume of the two hemispherical ends present on both sides of the cylindrical part. In this tutorial, we are going to discuss how to find the volume of a given capsule in Python using different approaches. Formula for Volume of Capsule The formula for the volume of a capsule is as follows: Volume of Capsule = ... Read More

Python program to find perimeter of rectangle

AYUSH MISHRA
Updated on 15-Jan-2025 18:55:09

4K+ Views

A rectangle is a closed two-dimensional figure having 4 sides. The opposite sides are equal and parallel. The angle made by the adjacent side is equal to 90 degrees. The perimeter is the sum of all sides; in other words, the perimeter is two times the sum of length and breadth. In this tutorial, we are going to learn how we can find the perimeter of a given rectangle in Python using different approaches. Formula of Perimeter of Rectangle The formula for the perimeter of a rectangle is as follows: Perimeter of Rectangle = 2 × (length + breadth) ... Read More

Mobile

Python program to find perimeter of square

AYUSH MISHRA
Updated on 15-Jan-2025 18:45:19

4K+ Views

A square is a closed two-dimensional figure having 4 equal sides. Each angle of a square is 90 degrees. The perimeter of a square is the sum of all its sides. Problem Description In this problem, we are given the side of a square, and we have to find the perimeter of the square. In this tutorial, we are going to find the perimeter of a given square in Python using different approaches. Example 1 Input: side = 6 units Output: 24 units Explanation Using the formula to calculate ... Read More

How to Copy a Tensor in PyTorch?

AYUSH MISHRA
Updated on 27-Dec-2024 15:14:04

4K+ Views

PyTorch is a very popular Python library used in machine learning. This library is developed by Facebook AI. This library provides robust tools for deep learning, neural networks, and tensor computations. Below are different approaches to Copying a Tensor in PyTorch. Using clone() function Using detach() method Using copy.deepcopy() method Using clone() function We use the clone() method to create a deep copy of a tensor. In deep copy, the original tensor and the copied tensor do not share memory. If we make changes in copied ... Read More

Python program to convert milliseconds to seconds

AYUSH MISHRA
Updated on 17-Dec-2024 11:25:20

2K+ Views

What is Milliseconds? The Milliseconds is a smaller unit of time used for problems where precise time calculations are desired. We can easily convert seconds to milliseconds using Python. In this article, we will learn how to do so in Python. This is useful in many applications, such as video editing, data analysis, and real-time processing. Problem Description We are given time input in milliseconds and must convert it into seconds. In this problem, we are going to learn how we can convert milliseconds to seconds in Python. The formula for converting milliseconds to seconds: seconds = 1000 / milliseconds ... Read More

Python program to convert seconds to milliseconds

AYUSH MISHRA
Updated on 12-Dec-2024 11:47:27

2K+ Views

Milliseconds is a smaller unit of time used for problems where precise time calculations are desired. We can easily convert seconds to milliseconds using Python. This is useful in many applications, such as video editing, data analysis, and real-time processing. Problem Description We are given time input in seconds and have to convert it into milliseconds. In this problem, we are going to learn how we can convert seconds to milliseconds in Python. The formula for converting seconds to milliseconds: Milliseconds = Seconds × 1000 Examples Input: 3 Output: 3000 Explanation: We know that, 1 second = 1000 milliseconds, ... Read More

How to install Python in Ubuntu?

Abhishek Nair
Updated on 21-Nov-2024 13:04:08

301 Views

Python is a powerful, open-source and easy to learn programming language. It is one of the most popular modern programming languages with a huge community of developers and extensive documentation. It usually comes pre-installed on all latest Linux systems as it is one of the building blocks of many operating system tools. Though, based on user requirement, one can install specific version of Python from available sources. In this tutorial, we will show you two ways to install Python on an Ubuntu system − Installing Python using package manager (apt) Installing Python using its source code Using Package ... Read More

What is COCOTB and How Does It Revolutionize Hardware Verification?

Moksh Gupta
Updated on 15-Nov-2024 18:54:41

227 Views

Verification in the world of digital hardware design is a crucial step for ensuring correctness and reliability of hardware components prior to fabrication. Traditional methods of verification usually rely on hardware description languages (HDLs), like Verilog or VHDL, together with contracted verification languages and schemes. But these approaches are cumbersome and kill productivity. Here comes Cocotb, a novel approach combining the power of Python for a radically new way of writing an HW verifier. What is Cocotb? Cocotb (COroutine based COsimulation TestBench) is a free open source framework that allows to write testbenches in python to verify hardware design described ... Read More

Advertisements