We have different ways to find the square of a number in python. In this post, I will show you different ways to do that with examples.
ReadPython list is used to hold same or different elements. All list elements are placed comma separated inside a square bracket []. You can access the list items and read/modify/delete them using index. The index starts from 0, i.e. 0 is the index of the first element, 1 is for the second element etc.
ReadLet’s say your frontend is showing the same value that backend sends and if your python backend needs to send numbers with comma as the thousand separators, it is actually pretty simple. For example, if the input is 1000, it should convert it to 1,000 and if it is 100000, it should convert it to 100,000.
ReadThis post will show you 4 different ways to create a list of objects in Python. We will learn how to use append, extend and insert methods to create a list of Python objects.
ReadPython strip() method is used for removing leading and trailing characters. It doesn't modify the original string. Actually it can't modify the string because it is immutable. It creates one copy of the string by removing the leading/trailing characters and returns that string.
Readcasefold() method is used to convert all characters in a string to lowercase. It doesn't take any parameter. You can directly call this method to a string. It returns the new lowercase character string.
ReadFinding out the trigonometric value like sine, cosine or tangent will be hard if we don’t use any package or library. Almost every programming language provides trigonometric functions. For python, these are defined in the math module. math module in Python provides different types of mathematical functions defined by the C standard. In this post, I will show you the list of all trigonometric functions defined in python math module with examples :.
ReadUsing enumeration can improve the readability of your code. Enumeration is a set of key-value pairs with each key is a symbolic name bound to its value. You can use the symbolic name in your code using enumeration to make it more readable.
Readmath module in python provides two different methods for a degree to radian and radian to degree conversion. Degree and radian are used for angle measurement and conversion of one to another are frequently used in applications like weather apps. You can write your own function to do the conversion but the math module already provides these functions. In this tutorial, I will show you how to use these math module functions.
ReadDefined in the math library, hypot() method is used to find the value of euclidean norm. For two numbers x and y, the euclidean norm is the length of the vector from origin (0,0) to the coordinate (x,y). For a point (x,y), it is equal to sqrt(x*x + y*y).
Read