Pavitra has Published 239 Answers

Find the highest 3 values in a dictionary in Python program

Pavitra

Pavitra

Updated on 23-Dec-2019 09:38:14

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.There are two approaches as discussed belowApproach 1: Using Collections.counter() functionExample Live Demo# collections module from collections import Counter ... Read More

Find sum of elements in list in Python program

Pavitra

Pavitra

Updated on 23-Dec-2019 09:36:59

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 compute the sum of the listHere we will be discussing 3 approaches as discussed belowUsing for loopExample Live Demo# sum total = 0 # creating a ... Read More

Find the sum of array in Python Program

Pavitra

Pavitra

Updated on 23-Dec-2019 09:32:23

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an array we need to compute the sum of the array.The brute-force approach to traverse the whole array and element at each index to obtain the sum is discussed below at ... Read More

Python program to find the smallest number in a list

Pavitra

Pavitra

Updated on 23-Dec-2019 09:30:14

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given al list, we need to display the smallest number available in the listHere we can either sort the list and get the smallest element or use the built-in min() function ... Read More

Python program to find the largest number in a list

Pavitra

Pavitra

Updated on 23-Dec-2019 08:09:45

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 calculate the largest element of the list.Here we will take the help of built-in functions to reach the solution of the problem statementUsing sort() functionExample# list ... Read More

Python Program to find the largest element in an array

Pavitra

Pavitra

Updated on 23-Dec-2019 08:07:18

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an array, we need to calculate the largest element of the array.Here we use the bruteforce approach in which we compute the largest element by traversing the whole loop and get ... Read More

Count upper and lower case characters without using inbuilt functions in Python program

Pavitra

Pavitra

Updated on 23-Dec-2019 07:54:17

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 uppercase and lowercase characters present in the string without using the inbuilt functionThis can be easily solved by using islower() and isupper() ... Read More

Python program to count the number of vowels using sets in a given string

Pavitra

Pavitra

Updated on 23-Dec-2019 07:46:01

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 vowels using sets in a given string.Here we are traverse through the whole string and check whether each character is a vowel ... Read More

Python program to convert seconds into hours, minutes and seconds

Pavitra

Pavitra

Updated on 23-Dec-2019 07:40:24

In this article, we will learn about the solution to the problem statement given below.Problem statement: We are given time, we need to convert seconds into hours & minutes to seconds.There are three approaches as discussed below−Approach 1: The brute-force methodExample Live Demodef convert(seconds):    seconds = seconds % (24 * ... Read More

Python Program to convert Kilometers to Miles

Pavitra

Pavitra

Updated on 23-Dec-2019 07:37:08

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given distance in kilometers and we need to convert it into milesAs we know that 1 kilometer equals 0.62137 miles.Formula UsedMiles = kilometer * 0.62137Now let’s observe the concept in the implementation ... Read More

Advertisements