Pradeep Elance has Published 445 Articles

degrees() and radians() in Python

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 12:08:06

590 Views

The measurements of angles in mathematics are done using these two units of measurement called degree and radian. They are frequently used in math calculations involving angles and need conversion from one value to another. In python we can achieve these conversions using python functions.degrees() FunctionThis function takes radian value ... Read More

Counting the frequencies in a list using dictionary in Python

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 11:53:22

2K+ Views

In this article we develop a program to calculate the frequency of each element present in a list.Using a dictionaryHere we capture the items as the keys of a dictionary and their frequencies as the values.Example Live Demolist = ['a', 'b', 'a', 'c', 'd', 'c', 'c'] frequency = {} for item ... Read More

chr () in Python

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 11:42:08

676 Views

This function return the string representing a character whose Unicode code point is the integer supplied as parameter to this function. For example, chr(65) returns the string 'A', while chr(126) returns the string '~'.SyntaxThe syntax of the function is as below.chr(n) where n is an integer valueExampleThe below program shows ... Read More

Change Data Type for one or more columns in Pandas Dataframe

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 11:30:14

2K+ Views

Many times we may need to convert the data types of one or more columns in a pandas data frame to accommodate certain needs of calculations. There are some in-built functions or methods available in pandas which can achieve this.Using astype()The astype() method we can impose a new data type ... Read More

Calculate n + nn + nnn + ? + n(m times) in Python

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 10:47:57

355 Views

There are a variety of mathematical series which python can handle gracefully. One such series is a series of repeated digits. Here we take a digit and add it to the next number which has two such digits and again the next number is three such digits and so on. ... Read More

howdoi in Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:58:23

237 Views

Create a Python ListExampleC:\Py3Project>howdoi create a python listOutputRunning the above code gives us the following result −>>> l = [None] * 10 >>> l [None, None, None, None, None, None, None, None, None, None]Printing Today’s DateExamplec:\python3>howdoi print today's date in pythonOutputRunning the above code gives us the following result −for ... Read More

How to print without newline in Python?

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:57:22

971 Views

In python the print statement adds a new line character by default. So when we have multiple print statements the output from each of them is printed in multiple lines as you can see in the example below. Our goal is to print them in a single line and use ... Read More

gcd() function Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:53:53

2K+ Views

Greatest common divisor or gcd is a mathematical expression to find the highest number which can divide both the numbers whose gcd has to be found with the resulting remainder as zero. It has many mathematical applications. Python has a inbuilt gcd function in the math module which can be ... Read More

floor() and ceil() function Python

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:53:20

2K+ Views

These two methods are part of python math module which helps in getting the nearest integer values of a fractional number.floor()It accepts a number with decimal as parameter and returns the integer which is smaller than the number itself.SyntaxSyntax: floor(x) Where x is a numeric valueExample of floor()In the below ... Read More

10 Interesting Python Cool Tricks

Pradeep Elance

Pradeep Elance

Updated on 08-Aug-2019 06:52:06

4K+ Views

With increase in popularity of python, more and more features are becoming available for python coding. Using this features makes writing the code in fewer lines and cleaner. In this article we will see 10 such python tricks which are very frequently used and most useful.Reversing a ListWe can simply ... Read More

Advertisements