Pavitra has Published 145 Articles

Multi-Line printing in Python

Pavitra

Pavitra

Updated on 30-Dec-2019 10:26:04

871 Views

We have usually seen the print command in python printing one line of output. But if we have multiple lines to print, then in this approach multiple print commands need to be written. This can be avoided by using another technique involving the three single quotes as seen below.Example Live Demoprint(''' ... Read More

Python-program-to-convert-pos-to-sop

Pavitra

Pavitra

Updated on 24-Dec-2019 05:55:35

231 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given pos form we need to convert it into its equivalent sop formThe conversion can be done by first counting the number of alphabets in the pos form and then calculating all ... Read More

Python program to print all Prime numbers in an Interval

Pavitra

Pavitra

Updated on 24-Dec-2019 05:46:13

530 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given an interval we need to compute all the prime numbers in a given rangeHere we will be discussing a brute-force approach to get the solution i.e. the basic definition of a ... Read More

Python program to insert an element into sorted list

Pavitra

Pavitra

Updated on 24-Dec-2019 05:30:25

1K+ 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 insert an element in a list without changing sorted orderThere are two approaches as discussed below−Approach 1: The brute-force methodExample Live Demodef insert(list_, n):    # search ... Read More

Python program to get all subsets of a given size of a set

Pavitra

Pavitra

Updated on 24-Dec-2019 05:26:57

902 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a set, we need to list all the subsets of size nWe have three approaches to solve the problem −Using itertools.combinations() methodExample Live Demo# itertools module import itertools def findsubsets(s, n):   ... Read More

Python Program to find whether a no is power of two

Pavitra

Pavitra

Updated on 24-Dec-2019 05:18:26

2K+ Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a number, we need to check that the number is a power of two or not.We can solve this using two approaches as discussed below.Approach 1: Taking the log of the ... Read More

Python program to find the smallest number in a list

Pavitra

Pavitra

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

357 Views

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

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

1K+ Views

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

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

Advertisements