0% found this document useful (0 votes)
18 views

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)
18 views

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
You are on page 1/ 5

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.
10.Sum of Natural Numbers
Write a Python program to calculate the sum of first 'n' natural numbers.
11.Check Prime Number
Write a Python program to check whether a number is prime or not.
12.Reverse a String
Write a Python program to reverse a given string.
13.Palindrome Check
Write a Python program to check if a given string or number is a palindrome.
14.Count Vowels in a String
Write a Python program to count the number of vowels in a string.
15.Print Multiplication Table
Write a Python program to print the multiplication table for a given number.
16.Swap Two Numbers
Write a Python program to swap two numbers without using a temporary variable.
17.Sum of Digits
Write a Python program to calculate the sum of digits of a number.
18.Check Armstrong Number
Write a Python program to check whether a number is an Armstrong number.
19.Find ASCII Value
Write a Python program to find the ASCII value of a character.
20.Convert Decimal to Binary
Write a Python program to convert a decimal number to binary.
21.Remove Duplicates from a List
Write a Python program to remove duplicate elements from a list.
22.Find Maximum Element in a List
Write a Python program to find the maximum element in a list.
23.Count Words in a String
Write a Python program to count the number of words in a string.
24.Merge Two Lists
Write a Python program to merge two lists into one.
25.Check Substring
Write a Python program to check if a string is a substring of another string.
Intermediate Level Problems
26.Find the Second Largest Number in a List
Write a Python program to find the second largest number in a list.
27.Matrix Addition
Write a Python program to add two matrices.
28.Matrix Multiplication
Write a Python program to multiply two matrices.
29.Transpose of a Matrix
Write a Python program to find the transpose of a matrix.
30.Find All Prime Numbers in an Interval
Write a Python program to find all prime numbers in a given interval.
31.GCD of Two Numbers
Write a Python program to find the greatest common divisor (GCD) of two numbers.
32.LCM of Two Numbers
Write a Python program to find the least common multiple (LCM) of two numbers.
33.Sort a List
Write a Python program to sort a list of numbers in ascending order.
34.Find the Median of a List
Write a Python program to find the median of a list of numbers.
35.Count Frequency of Elements in a List
Write a Python program to count the frequency of each element in a list.
36.Check Anagram
Write a Python program to check if two strings are anagrams of each other.
37.Quadratic Equation Solver
Write a Python program to find the roots of a quadratic equation.
38.Create a Simple Calculator
Write a Python program to create a simple calculator that performs addition,
subtraction, multiplication, and division.
39.Find the Sum of Elements in a List
Write a Python program to find the sum of elements in a list.
40.Find Common Elements Between Two Lists
Write a Python program to find common elements between two lists.
41.Check Perfect Number
Write a Python program to check whether a number is a perfect number.
42.Count Occurrences of a Substring
Write a Python program to count occurrences of a substring in a string.
43.Binary Search Algorithm
Write a Python program to implement the binary search algorithm.
44.Bubble Sort Algorithm
Write a Python program to implement the bubble sort algorithm.
45.Linear Search Algorithm
Write a Python program to implement the linear search algorithm.
46.Find the Sum of Even Numbers in a List
Write a Python program to find the sum of all even numbers in a list.
47.Calculate the Power of a Number
Write a Python program to calculate the power of a number using recursion.
48.Check Sublist
Write a Python program to check if a list is a sublist of another list.
49.Find the Length of the Longest Word in a String
Write a Python program to find the length of the longest word in a string.
50.Create 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.
10.Find 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().
11.Flatten a Nested List
Write a Python program to flatten a list that contains nested lists.
12.Count 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().
13.Find 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.
14.Check 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).
15.Rotate a List
Write a Python program to rotate a list by 'n' positions to the left.
16.Calculate 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).
17.Find the Longest Common Prefix
Write a Python program to find the longest common prefix among a list of strings.
18.Check for Palindromic Substrings
Write a Python program to find all palindromic substrings in a given string.
19.Count the Number of Digits in a Number
Write a Python program to count how many digits are in a given number.
20.Find the Greatest Difference in a List
Write a Python program to find the greatest difference between two elements in a list.
21.Find the Intersection of Two Lists
Write a Python program to find the intersection (common elements) of two lists.
22.Check if a List is Sorted
Write a Python program to check if a list is sorted in ascending or descending order.
23.Replace All Occurrences of a Substring
Write a Python program to replace all occurrences of a given substring in a string
with another substring.
24.Create a Frequency Dictionary from a List
Write a Python program to create a frequency dictionary from a list, showing how
often each element appears.
25.Find Missing Numbers in a Sequence
Write a Python program to find missing numbers in a given sequence of numbers.
26.Check if a Matrix is Symmetric
Write a Python program to check if a matrix is symmetric (equal to its transpose).
27.Generate Random Unique Numbers
Write a Python program to generate 'n' unique random numbers within a given range.
28.Caesar Cipher Encryption and Decryption
Write a Python program to implement Caesar cipher encryption and decryption.
29.Find 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.
30.Find the Longest Increasing Subsequence
Write a Python program to find the longest increasing subsequence in a list of
numbers.

You might also like