## Count positive and negative numbers in a list in Python program Pavitra

Updated on 11-Jul-2020 11:24:45

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list iterable, we need to count positive and negative numbers in it and display them.Approach 1 − Brute-force approach using iteration construct(for)Here we need to iterate each element in the ... Read More

## Python program to print odd numbers in a list Pavitra

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

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 even numbers in a list Pavitra

Updated on 04-Jul-2020 12:56:14

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 even 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 print negative numbers in a list Pavitra

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

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

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

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

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

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

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

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 count positive and negative numbers in a list Pavitra

Updated on 04-Jul-2020 12:39:53

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 count all the positive and negative numbers available in the iterable.Her we will be discussing two approaches −Brute-force approachUsing lambda inline functionApproach 1 − Brute-force methodExample Live ... Read More

## Python program to count words in a sentence Pavitra

Updated on 04-Jul-2020 12:38:09

In this article, we will learn about the solution and approach to solve the given problem statement.Problem statementWe are given a sentence, we need to count the number of words in the sentenceHere we will be discussing two approaches −Approach 1 − Using split() functionExample Live Demotest_string = "Tutorials point " ... Read More

## Python program to find largest number in a list Pavitra

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

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