Pavitra has Published 145 Articles

Python program to print odd numbers in a list

Pavitra

Pavitra

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

3K+ 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

752 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 the highest 3 values in a dictionary

Pavitra

Pavitra

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

3K+ 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

1K+ 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

300 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

Intersection() function Python

Pavitra

Pavitra

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

243 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

240 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

2K+ 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

Iterate over a list in Python

Pavitra

Pavitra

Updated on 01-Jul-2020 07:13:07

443 Views

In this article, we will learn about iterating/traversing over a list in Python 3.x. Or earlier.A list is an ordered sequence of elements. It is a non-scalar data structure and mutable in nature. A list can contain distinct data types in contrast to arrays storing elements belonging to the same ... Read More

Iterate over characters of a string in Python

Pavitra

Pavitra

Updated on 01-Jul-2020 07:10:14

2K+ Views

In this article, we will learn about iterating/ traversing over characters of a string in Python 3.x. Or earlier.The string is a collection of characters which may contain spaces, alphabets or integers. They can be accessed using indexes or via references . Some commonly implemented methods are shown below.Method 1 ... Read More

Advertisements