0% found this document useful (0 votes)
31 views5 pages

Python Problem Examples

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Python Problem Examples

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic Level Problems

1. Print Hello World


Write a Python program to print "Hello, World!" to the console.
2. Sum of Two Numbers
Write a Python program to input two numbers and output their sum.
3. Check Even or Odd
Write a Python program to check whether a number is even or odd.
4. Find the Largest Number
Write a Python program to find the largest of three numbers.
5. Simple Interest Calculator
Write a Python program to calculate simple interest (S.I. = P * R * T / 100).
6. Temperature Converter
Write a Python program to convert temperature from Celsius to Fahrenheit.
7. Check Leap Year
Write a Python program to check if a year is a leap year.
8. Factorial of a Number
Write a Python program to find the factorial of a number using recursion.
9. Generate Fibonacci Sequence
Write a Python program to print the Fibonacci sequence up to 'n' terms.
[Link] of Natural Numbers
Write a Python program to calculate the sum of first 'n' natural numbers.
[Link] Prime Number
Write a Python program to check whether a number is prime or not.
[Link] a String
Write a Python program to reverse a given string.
[Link] Check
Write a Python program to check if a given string or number is a palindrome.
[Link] Vowels in a String
Write a Python program to count the number of vowels in a string.
[Link] Multiplication Table
Write a Python program to print the multiplication table for a given number.
[Link] Two Numbers
Write a Python program to swap two numbers without using a temporary variable.
[Link] of Digits
Write a Python program to calculate the sum of digits of a number.
[Link] Armstrong Number
Write a Python program to check whether a number is an Armstrong number.
[Link] ASCII Value
Write a Python program to find the ASCII value of a character.
[Link] Decimal to Binary
Write a Python program to convert a decimal number to binary.
[Link] Duplicates from a List
Write a Python program to remove duplicate elements from a list.
[Link] Maximum Element in a List
Write a Python program to find the maximum element in a list.
[Link] Words in a String
Write a Python program to count the number of words in a string.
[Link] Two Lists
Write a Python program to merge two lists into one.
[Link] Substring
Write a Python program to check if a string is a substring of another string.
Intermediate Level Problems
[Link] the Second Largest Number in a List
Write a Python program to find the second largest number in a list.
[Link] Addition
Write a Python program to add two matrices.
[Link] Multiplication
Write a Python program to multiply two matrices.
[Link] of a Matrix
Write a Python program to find the transpose of a matrix.
[Link] All Prime Numbers in an Interval
Write a Python program to find all prime numbers in a given interval.
[Link] of Two Numbers
Write a Python program to find the greatest common divisor (GCD) of two numbers.
[Link] of Two Numbers
Write a Python program to find the least common multiple (LCM) of two numbers.
[Link] a List
Write a Python program to sort a list of numbers in ascending order.
[Link] the Median of a List
Write a Python program to find the median of a list of numbers.
[Link] Frequency of Elements in a List
Write a Python program to count the frequency of each element in a list.
[Link] Anagram
Write a Python program to check if two strings are anagrams of each other.
[Link] Equation Solver
Write a Python program to find the roots of a quadratic equation.
[Link] a Simple Calculator
Write a Python program to create a simple calculator that performs addition,
subtraction, multiplication, and division.
[Link] the Sum of Elements in a List
Write a Python program to find the sum of elements in a list.
[Link] Common Elements Between Two Lists
Write a Python program to find common elements between two lists.
[Link] Perfect Number
Write a Python program to check whether a number is a perfect number.
[Link] Occurrences of a Substring
Write a Python program to count occurrences of a substring in a string.
[Link] Search Algorithm
Write a Python program to implement the binary search algorithm.
[Link] Sort Algorithm
Write a Python program to implement the bubble sort algorithm.
[Link] Search Algorithm
Write a Python program to implement the linear search algorithm.
[Link] the Sum of Even Numbers in a List
Write a Python program to find the sum of all even numbers in a list.
[Link] the Power of a Number
Write a Python program to calculate the power of a number using recursion.
[Link] Sublist
Write a Python program to check if a list is a sublist of another list.
[Link] the Length of the Longest Word in a String
Write a Python program to find the length of the longest word in a string.
[Link] a Dictionary from Two Lists
Write a Python program to create a dictionary by mapping two lists of keys and
values.
Basic to Intermediate Level Problems
1. Count Occurrences of Each Character
Write a Python program to count the occurrences of each character in a given string.
2. Reverse a List
Write a Python program to reverse a list without using any built-in reverse methods.
3. Merge and Sort Two Lists
Write a Python program to merge two lists and sort the resulting list.
4. Find the Mode of a List
Write a Python program to find the mode (the most frequent element) of a list.
5. Remove Punctuation from a String
Write a Python program to remove all punctuation from a string.
6. Generate a Random Password
Write a Python program to generate a random password with a mix of uppercase,
lowercase, numbers, and special characters.
7. Check for a Perfect Square
Write a Python program to check if a number is a perfect square.
8. Check if a Number is a Power of Two
Write a Python program to check if a number is a power of two.
9. Calculate Compound Interest
Write a Python program to calculate compound interest.
[Link] the Largest and Smallest Elements in a List Without Built-in Functions
Write a Python program to find the largest and smallest elements in a list without
using max() and min().
[Link] a Nested List
Write a Python program to flatten a list that contains nested lists.
[Link] Occurrences of an Element in a List Without Built-in Functions
Write a Python program to count the occurrences of a specific element in a list without
using count().
[Link] the Sum of a List of Numbers Using Recursion
Write a Python program to find the sum of all elements in a list using recursion.
[Link] if Two Lists are Identical
Write a Python program to check if two lists are identical (i.e., have the same elements
in the same order).
[Link] a List
Write a Python program to rotate a list by 'n' positions to the left.
[Link] the Hamming Distance Between Two Strings
Write a Python program to calculate the Hamming distance between two strings of
equal length (the number of positions at which they differ).
[Link] the Longest Common Prefix
Write a Python program to find the longest common prefix among a list of strings.
[Link] for Palindromic Substrings
Write a Python program to find all palindromic substrings in a given string.
[Link] the Number of Digits in a Number
Write a Python program to count how many digits are in a given number.
[Link] the Greatest Difference in a List
Write a Python program to find the greatest difference between two elements in a list.
[Link] the Intersection of Two Lists
Write a Python program to find the intersection (common elements) of two lists.
[Link] if a List is Sorted
Write a Python program to check if a list is sorted in ascending or descending order.
[Link] All Occurrences of a Substring
Write a Python program to replace all occurrences of a given substring in a string
with another substring.
[Link] a Frequency Dictionary from a List
Write a Python program to create a frequency dictionary from a list, showing how
often each element appears.
[Link] Missing Numbers in a Sequence
Write a Python program to find missing numbers in a given sequence of numbers.
[Link] if a Matrix is Symmetric
Write a Python program to check if a matrix is symmetric (equal to its transpose).
[Link] Random Unique Numbers
Write a Python program to generate 'n' unique random numbers within a given range.
[Link] Cipher Encryption and Decryption
Write a Python program to implement Caesar cipher encryption and decryption.
[Link] All Pairs with a Given Sum
Write a Python program to find all pairs of numbers in a list that add up to a given
target sum.
[Link] the Longest Increasing Subsequence
Write a Python program to find the longest increasing subsequence in a list of
numbers.

You might also like