Pavitra has Published 177 Articles

Python program to print odd numbers in a list

Pavitra

Pavitra

Updated on 04-Jul-2020 13:00:29

2K+ Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a list iterable as input, we need to display odd numbers in the given iterable.Here we will be discussing three different approaches to solve this problem.Approach 1 − Using enhanced for loopExamplelist1 ... Read More

Python program to print negative numbers in a list

Pavitra

Pavitra

Updated on 04-Jul-2020 12:54:55

555 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a list iterable, we need to print all the negative numbers in the list.Here we will be discussing three approaches for the given problem statement.Approach 1 − Using enhanced for loopExamplelist1 = ... Read More

Python program to find sum of elements in list

Pavitra

Pavitra

Updated on 04-Jul-2020 12:45:28

380 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven an list as an input, we need to compute the sum of the given list.Here we have two approaches to consider i.e. using built-in function & using the brute-force approach.Approach 1 − ... Read More

Python program to find the highest 3 values in a dictionary

Pavitra

Pavitra

Updated on 04-Jul-2020 12:44:08

2K+ Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a dictionary, we need to find the three highest valued values and display them.Approach 1 − Using the collections module ( Counter function )Example Live Demofrom collections import Counter # Initial Dictionary my_dict ... Read More

Python program to convert decimal to binary number

Pavitra

Pavitra

Updated on 04-Jul-2020 12:41:01

888 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven a number we need to convert into a binary number.Approach 1 − Recursive SolutionDecToBin(num):    if num > 1:       DecToBin(num // 2)       print num % 2Exampledef ... Read More

Python program to find largest number in a list

Pavitra

Pavitra

Updated on 04-Jul-2020 12:37:12

215 Views

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementGiven list input, we need to find the largest numbers in the given list .Here we will discuss two approachesUsing sorting techniquesUsing built-in max() functionApproach 1 − Using built-in sort() functionExample Live Demolist1 = ... Read More

Mathematical Functions in Python - Special Functions and Constants

Pavitra

Pavitra

Updated on 03-Jul-2020 07:59:03

196 Views

In this article, we will learn about special functions and constants available in the math module in the Python Standard Library.Here we will discuss some constants like −pieinfNantauAnd some functions likeGammaIsinfIsnanisfinite()erf()Let's discuss constants and their respective values −pi3.141592…..e2.718281…...inf6.283185…...nantauNow let’s discuss some special functions and their implementation −Gamma − return the ... Read More

Intersection() function Python

Pavitra

Pavitra

Updated on 03-Jul-2020 07:54:35

132 Views

In this article, we will learn about intersection() function that can be performed on any given set. According to mathematics intersection means finding out common elements from the two sets.Syntax.intersection( ……..)Return Value common elements in sets passed as arguments.Exampleset_1 = {'t', 'u', 't', 'o', 'r', 'i', 'a', 'l'} set_2 = ... Read More

isdisjoint() function in Python

Pavitra

Pavitra

Updated on 03-Jul-2020 07:53:20

125 Views

In this article, we will learn about how we can implement isdisjoint() function on set() data type. This function checks whether the sets passed as arguments have any element in common . In case any element is found, False is returned and True otherwise.The isdisjoint() function can take lists, tuples ... Read More

isupper(), islower(), lower(), upper() in Python and their applications

Pavitra

Pavitra

Updated on 03-Jul-2020 07:51:06

1K+ Views

In this article, we will learn about isupper(), islower() ,upper() , lower() function in Python 3.x. or earlier.These are the functions that can be used on strings and related types. They are included in Python Standard Library.All the functions accept no arguments. The isupper() & islower() return boolean values whereas ... Read More

Advertisements