Find Power of a Number in Python

Vikram Chiluka
Updated on 28-Oct-2022 11:33:35

14K+ Views

In this article, we will show you how to find the power of a number in python. Below are the various methods to accomplish this task − Using for loop Using Recursion Using pow() function Using ** operator Using for loop Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task –. Create a function findPower() that returns the power of a Number. The function accepts number, and exponent value as parameters. Take a variable that stores the result and initialize its value with 1. To obtain the power, multiply the given ... Read More

Find HCF or GCD Using Python

Vikram Chiluka
Updated on 28-Oct-2022 11:31:48

2K+ Views

In this article, we will show you how to find the HCF (Highest Common Factor) or GCD (Greatest Common Factor) in Python. Below are the various methods to accomplish this task: Using For Loop Using Euclidean Algorithm Using While Loop Using Recursion(Naive method) Handling Negative Numbers in HCF What is H.C.F. or G.C.D? The largest positive integer that perfectly divides the two given numbers is known as the highest common factor (H.C.F.) or greatest common divisor (G.C.D.). Example - The HCF of 12 and 14, is 2. Using For Loop Algorithm (Steps) Following are the Algorithm/steps to be followed to ... Read More

Python Math at Command Line

Vikram Chiluka
Updated on 28-Oct-2022 11:29:37

2K+ Views

In this article, we will show you how to do python math at the command line. Python is an interpreter-based language. When you invoke the Python interpreter, (>>>) Python prompt appears. Any Python statement can be entered in front of it. As soon as you press ENTER, the statement is executed. Hence a mathematical expression using operators defined in Python will be evaluated at the command line. What are Operators? A symbol or function that represents an operation is called an operator. For instance, in mathematics, the addition operator is represented by the plus sign (+). While some of ... Read More

What is Odometry?

Jay Singh
Updated on 28-Oct-2022 11:27:50

3K+ Views

In a search and retrieval challenge like the Robo-Rat competition, it is critical for a robot to be aware of its location. It might not seem like a difficult effort to know where you are, but as you shall see, it can be really difficult. People can locate themselves using their sharp vision, long-term memories, and awareness of their surroundings. However, robots do not naturally possess these sophisticated abilities, especially the ones you will be developing for this class. Odometry is one technique that robots use to locate themselves in their surroundings. What is Odometry? The measurement of a robot's ... Read More

Generate Random Integers Between 0 and 9 Using Python

Vikram Chiluka
Updated on 28-Oct-2022 11:23:17

3K+ Views

In this article, we will show you how to generate random integers between 0 and 9 in Python. Below are the various methods to accomplish this task: Using randint() method Using randrange() method Using secrets module To generate random integers within certain ranges, Python supports a variety of functions. We will discuss Python's built-in random module for generating random numbers. The two primary functions provided by the random module to produce random integers are randint() and randrange(). In order to produce random values, a second module called secrets is also used. Using randint() method The random.randint() method is ... Read More

Draw the Solar System

Kiran Kumar Panigrahi
Updated on 28-Oct-2022 08:20:43

2K+ Views

The Sun is at the center of our Solar System and around it revolve eight planets and several moons. The eight planets in the increasing order of their distance from the Sun are Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune. Pluto was regarded as the ninth planet until 2006 after which the International Astronomical Union decided to downgrade it to a dwarf planet. In this step-by-step guide, learn how you can draw a model diagram of Solar System. It is quite easy to draw the Solar System once you know the placement of the planets around the Sun. ... Read More

Make a Simple Calculator Using Switch Case in Golang

Akhil Sharma
Updated on 28-Oct-2022 07:58:28

5K+ Views

In this tutorial we will see how to make a simple calculator using switch case statements in Go programming language. The switch statement will assess an expression, comparing the expression's value against a series of case conditions given in a series and executes the statement after the first condition with a matching value, until a break is encountered. Golang Basic switch case with default A switch statement runs the first case equal to the choice entered. The cases are evaluated in an order and it stops when a case succeeds. If no case (choice entered) matches, it is a ... Read More

Straighten Image with Animation Using Fabric.js

Rahul Gurung
Updated on 28-Oct-2022 07:53:12

244 Views

In this tutorial, we are going to learn how to straighten an Image with animation using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to straighten an Image with animation, we use the fxStraighten method. Syntax fxStraighten(callbacks: Object): fabric.Object Parameters callbacks − This parameter is an Object with callback functions which can be used to change certain properties related to the animation. Using the straighten method Example ... Read More

Straighten Image Object Using Fabric.js

Rahul Gurung
Updated on 28-Oct-2022 07:50:24

343 Views

In this tutorial, we are going to learn how to straighten an Image object using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to straighten an Image object, we use the straighten method. Syntax straighten(): fabric.Object Passing the angle property a value without using the straighten method Example Let’s see a code example to see how our Image object looks when the straighten method is not used. The straighten ... Read More

Set Image Position from Top Using FabricJS

Rahul Gurung
Updated on 28-Oct-2022 07:48:44

553 Views

In this tutorial, we are going to learn how to set the position of Image from top using FabricJS. We can create an Image object by creating an instance of fabric.Image. Since it is one of the basic elements of FabricJS, we can also easily customize it by applying properties like angle, opacity etc. In order to set the position of Image from top, we use the top property. Syntax new fabric.Image( element: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | String, { top: Number }: Object, callback: function) Parameters element − This parameter accepts HTMLImageElement, HTMLCanvasElement, HTMLVideoElement or String ... Read More

Advertisements