Pradeep Elance has Published 446 Articles

exec() in Python

Pradeep Elance

Pradeep Elance

Updated on 23-Aug-2019 12:15:41

895 Views

Exec function can dynamically execute code of python programs. The code can be passed in as string or object code to this function. The object code is executed as is while the string is first parsed and checked for any syntax error. If no syntax error, then the parsed string ... Read More

degrees() and radians() in Python

Pradeep Elance

Pradeep Elance

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

551 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

622 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

333 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

210 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

912 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

Advertisements