Pavitra has Published 177 Articles

Count words in a sentence in Python program

Pavitra

Pavitra

Updated on 25-Aug-2023 02:03:41

32K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a string we need to count the number of words in the stringApproach 1 − Using split() functionThe split() function breaks the string into a list iterable with space as a ... Read More

Twitter Sentiment Analysis using Python Program

Pavitra

Pavitra

Updated on 16-May-2022 12:23:58

329 Views

In this article, we will be learning about the twitter sentimental analysis. We will register for twitter oAuth API, install all the dependencies and finally write our sentimental analyzer script.An API(Application programming interface) is a gateway that allows you to access some servers(Twitter) internal functionality.The prerequisite is that we have ... Read More

Python program to interchange first and last elements in a list

Pavitra

Pavitra

Updated on 11-Jul-2020 12:01:53

400 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list, we need to swap the last element with the first element.There are 4 approaches to solve the problem as discussed below−Approach 1 − The brute-force approachExample Live Demodef swapLast(List):   ... Read More

Python program to find the sum of all items in a dictionary

Pavitra

Pavitra

Updated on 11-Jul-2020 11:56:02

542 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a dictionary, and we need to print the 3 highest value in a dictionary.Three approaches to the problem statement are given below:Approach 1 − Calculating sum from the dictionary iterableExample Live Demo# ... Read More

Python program to create a dictionary from a string

Pavitra

Pavitra

Updated on 11-Jul-2020 11:32:35

532 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a string input, we need to convert it into dictionary typeHere we will discuss two methods to solve the problem without using a built-in dict() function.Method 1 − Using eval() methodEval ... Read More

Python program to find occurrence to each character in given string

Pavitra

Pavitra

Updated on 11-Jul-2020 11:31:49

1K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a string, we need to find the occurrence of each character in a given string.Here we will be discussing 3 approaches as discussed below:LApproach 1 − The brute-force approachExample Live Demotest_str = ... Read More

Python program to find the second largest number in a list

Pavitra

Pavitra

Updated on 11-Jul-2020 11:30:42

3K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list, we need to display the second largest number in a list.There are three approaches to solve the problem−Approach 1 − We use the set() function & remove() functionExample Live Demolist1 ... Read More

Python program to find the second maximum value in Dictionary

Pavitra

Pavitra

Updated on 11-Jul-2020 11:28:51

532 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given two integers, we need to print the second maximum value in the dictionaryNow let’s observe the concept in the implementation below−Approach 1 − Using sorted() function by negative indexesExample Live Demo#input example_dict ... Read More

Python program to Count Even and Odd numbers in a List

Pavitra

Pavitra

Updated on 11-Jul-2020 11:25:39

4K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list, we need to count even and odd numbers in a list.There are three methods as discussed below−Approach 1 − Using brute-force approachExample Live Demolist1 = [21, 3, 4, 6, 33, ... Read More

Count positive and negative numbers in a list in Python program

Pavitra

Pavitra

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

3K+ Views

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

1 2 3 4 5 ... 18 Next
Advertisements