Category: Python Programming Examples

python tutorials and learn python

Created with Sketch.

Python | Sort Python Dictionaries by Key or Value

Python | Sort Python Dictionaries by Key or Value Problem Statement – Here are the major tasks that are needed to be performed. Create a dictionary and display its keys alphabetically. Display both the keys and values sorted in alphabetical order by the key. Same as part (ii), but sorted in alphabetical order by the…
Read more

Reverse words in a given String in Python

Reverse words in a given String in Python We are given a string and we need to reverse words of given string ? Examples: Input : str = ” quiz practice code” Output : str = “code practice quiz ” This problem has existing solution please refer Reverse words in a given String link. We…
Read more

Python program to check if a string is palindrome or not

Python program to check if a string is palindrome or not Given a string, write a python function to check if it is palindrome or not. A string is said to be palindrome if reverse of the string is same as string. For example, “radar” is palindrome, but “radix” is not palindrome. Examples: Input :…
Read more

Break a list into chunks of size N in Python

Break a list into chunks of size N in Python Method 1: Using yield The yield keyword enables a function to comeback where it left off when it is called again. This is the critical difference from a regular function. A regular function cannot comes back where it left off. The yield keyword helps a…
Read more

Python program to find Cumulative sum of a list

Python program to find Cumulative sum of a list The problem statement asks to produce a new list whose element will be equal to the sum of the elements. Examples : Input : list = [10, 20, 30, 40, 50] Output : [10, 30, 60, 100, 150] Input : list = [4, 10, 15, 18,…
Read more

Python | Program to print duplicates from a list of integers

Python | Program to print duplicates from a list of integers Given a list of integers with duplicate elements in it. The task to generate another list, which contains only the duplicate elements. In simple words, the new list should contain the elements which appear more than one. Examples : Input : list = [10,…
Read more

Python | Remove empty tuples from a list

Python | Remove empty tuples from a list In this article, we will see how can we remove an empty tuple from a given list of tuples. We will find various ways, in which we can perform this task of removing tuples using various methods and ways in Python. Examples: Input : tuples = [(),…
Read more

Remove multiple elements from a list in Python

Remove multiple elements from a list in Python Given a list of numbers, write a Python program to remove multiple elements from a list based on the given condition. Example: Input: [12, 15, 3, 10] Output: Remove = [12, 3], New_List = [15, 10] Input: [11, 5, 17, 18, 23, 50] Output: Remove = [1:5],…
Read more

Python program to count positive and negative numbers in a list

Counting Positive and Negative Numbers in a List using Python In this comprehensive blog post, we will delve into the Python programming language to create a program that counts positive and negative numbers in a given list. The article will provide an in-depth explanation of the algorithm used, include the Python code for implementation, and…
Read more

Python program to print all negative numbers in a range

Python Program: Print All Negative Numbers in a Range In this blog post, we’ll explore a Python program designed to print all negative numbers within a specified range. We’ll provide a detailed explanation of the algorithm, present the Python code, and include examples with corresponding outputs. Understanding the Algorithm The algorithm for printing negative numbers…
Read more