Scipy linalg Norm in Python

Syed Abeed
Updated on 22-Dec-2021 10:05:34

585 Views

The norm() function of the scipy.linalg package is used to return one of eight different matrix norms or one of an infinite number of vector norms.Syntaxscipy.linalg.norm(x)Where x is an input array or a square matrix.Example 1Let us consider the following example −# Importing the required libraries from scipy from scipy import linalg import numpy as np # Define the input array x = np.array([7 , 4]) print("Input array:", x) # Calculate the L2 norm r = linalg.norm(x) # Calculate the L1 norm s = linalg.norm(x, 3) # Display the norm values print("Norm Value of r :", ... Read More

Compute Inverse of a Matrix using SciPy linalg.inv

Syed Abeed
Updated on 22-Dec-2021 10:02:40

401 Views

The scipy.linalg package contains a of different functionalities that are used for Linear Algebra. One of them is the inv() function, which is used to find the inverse of a square matrix.Syntaxscipy.linalg.inv(x)Where x is a square matrix.Example 1Let us consider the following example −# Import the required libraries from scipy import linalg import numpy as np # defines the array a = np.array([[5, 3], [6, 4]]) print("Input matrix :", a) # Finding the inverse of a square matrix x = linalg.inv(a) print(" Inverse of Square Matrix A :", x)OutputThe above program will generate the following output −Input matrix ... Read More

Compute Determinant using SciPy linalg.det in Python

Syed Abeed
Updated on 22-Dec-2021 09:59:56

321 Views

The scipy.linalg package contains a set of different functionalities that are used for Linear Algebra. One of them is the det() function. This function is used to find the determinant of a two-dimensional matrix.Syntaxscipy.linalg.det(x)Where x is a square matrix.Example 1Let us consider the following example −# Importing the required libraries from scipy import linalg import numpy as np # Initialize the matrix A A = np.array([[8, 5], [3, 4]]) print("Input Matrix :", A) # Find the determinant of matrix X x = linalg.det(A) print("Determinant Value of A:", x)OutputIt will generate the following output −Input Matrix : [[8 5] ... Read More

Python Scipy Special logsumexp Function

Syed Abeed
Updated on 22-Dec-2021 09:54:51

2K+ Views

The scipy.special package contains a set of different functionalities that are used for mathematical physics. One of them is the logsumexp() function. This function is used to compute the log of the sum of exponentials of input elements. Let us take a couple of examples and see how to use this function.Syntaxscipy.special.logsumexp(x)where, x is the input value.Example 1Let us consider the following example −# Import logsumexp from scipy.special from scipy.special import logsumexp import numpy as np # Input array a = np.arange(10) print("Input Array:", a) # logsum() function res = logsumexp(a) print("logsumexp of a:", res)OutputIt will produce the ... Read More

Use Small Font in HTML

karthikeya Boyini
Updated on 22-Dec-2021 09:43:02

5K+ Views

To set the small font in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML tag, with the CSS property font-size. HTML5 do not support the tag, so the CSS style is used to add font size.Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML tag or external style sheet.ExampleYou can try the following code to add font smaller than the default font in an HTML page     ... Read More

Create an Impressive GUI in Python Using Tkinter

Dev Prakash Sharma
Updated on 22-Dec-2021 08:19:41

1K+ Views

Tkinter is a standard Python GUI library in Python, which gives us an object-oriented interface with Tk GUI Toolkit. It's amazing how quickly one can create some really impressive looking apps. Actions in GUI are usually performed through direct manipulation of graphical elements.We will take a simple "addition" application to show how easy it is to create an impressive GUI in Python using tkinter. GUI is all about widgets and windows and these are available in Tkinter.First, we will import the Tkinter library, then create a window object (class Tk is used to create window object) and create a label ... Read More

Directly Modify a Specific Item in a Tkinter Listbox

Dev Prakash Sharma
Updated on 22-Dec-2021 08:13:47

1K+ Views

Tkinter is a Python-based GUI application development library which is generally used to build useful functional desktop applications. The Listbox widget is another tkinter widget, which is used as a container to display a list of items in the form of a Listbox.To define a list of items in a Listbox widget, you'll need to create a constructor of Listbox(root, width, height, **options). You can insert as many items as you want to display in the listbox.Suppose you want to modify a specific item in a tkinter Listbox, then you can first create a button to select the item from ... Read More

Change Background Color of a Tkinter Canvas Dynamically

Dev Prakash Sharma
Updated on 22-Dec-2021 08:11:43

20K+ Views

The Canvas widget is one of the most useful widgets in Tkinter. It has various functionalities and features to help developers customize the application according to their need. The Canvas widget is used to display the graphics in an application. You can create different types of shapes and draw objects using the Canvas widget.To change the background color of the Canvas widget, you can use the configure() method. Here, you can specify the background color of the Canvas widget which you want to change explicitly.ExampleIn the following example, we have created a canvas widget with a default background color "skyblue", ... Read More

Explicitly Resize Frames in Tkinter

Dev Prakash Sharma
Updated on 22-Dec-2021 08:10:07

7K+ Views

The Frames widget in tkinter is generally used to display widgets in the form of a container. The Frame widget works similar to the default window container. The geometry and size of the frame widget can be configured using various geometry managers available in the tkinter library.Considering the case, if you want to configure the size of the frame explicitly, you can use the pack() geometry manager by specifying the side and padding property. The pack() geometry manager gives proper accessibility to the widget for resizing.ExampleIn the following example, we will create two frames and resize them using the pack() ... Read More

Create Colored Lines Based on Length in Tkinter

Dev Prakash Sharma
Updated on 22-Dec-2021 08:06:11

2K+ Views

Tkinter Canvas widget is one of the versatile widgets which is generally used to draw shapes, arcs, objects, display images or any content. The objects inside the Canvas widget can be modified as well as configured using the configure() method or within the constructor by providing values to the properties.To create lines on a Canvas widget, you can use the create_lines(x0, x1, x2, x3, fill="color", width, **options) constructor. In the constructor, you can assign the values of x0(top), x1(right), x2(bottom) and x3(left) which would decide the length of the lines to be drawn inside the canvas widget.ExampleLet's take an example ... Read More

Advertisements