A collection of 100 Python practice problems designed to help you improve your coding skills. These problems cover a wide range of topics from basic programming concepts to more advanced exercises, including string manipulation, data structures, algorithms, and more.
This repository contains a variety of Python practice problems suitable for beginners and intermediate programmers. Whether you're just starting out or looking to hone your skills, these exercises will challenge you and help you become more proficient in Python programming.
- Find the Oldest Age: User will input three ages. Find the oldest one.
- Celsius to Fahrenheit Converter: Write a program that will convert Celsius value to Fahrenheit.
- Swap Two Numbers: User will input two numbers. Write a program to swap the numbers.
- Sum of Digits: Write a program that will give you the sum of 3 digits.
- Reverse a Number and Check: Write a program that will reverse a four-digit number and check whether the reverse is the same as the original.
- Odd or Even: Write a program that will tell whether the number entered by the user is odd or even.
- Leap Year Checker: Write a program that will tell whether the given year is a leap year or not.
- Euclidean Distance: Write a program to find the Euclidean distance between two coordinates.
- Triangle Checker: Write a program that takes user input of three angles and determines whether they can form a triangle.
- Profit or Loss Calculator: Write a program that will take user input of cost price and selling price and determine whether it’s a loss or a profit.
- Simple Interest Calculator: Write a program to find the simple interest when the value of the principal, rate of interest, and time period is given.
- Volume of Cylinder and Cost Calculator: Write a program to find the volume of a cylinder. Also, find the cost when the cost of 1 litre of milk is 40 Rs.
- Divisibility Checker: Write a program that will tell whether the given number is divisible by both 3 and 6.
- Angle Between Hour and Minute Hand: Solve the problem here.
- Overlapping Rectangles: Solve the problem here.
- Weather Predictor: Write a program that determines the weather based on user-provided temperature and humidity.
- TEMPERATURE(C) | HUMIDITY(%) | WEATHER
>= 30
|>= 90
| Hot and Humid>= 30
|< 90
| Hot< 30
|>= 90
| Cool and Humid< 30
|< 90
| Cool
- Sum of Squares: Write a program that will take three digits from the user and return the sum of the squares of each digit.
- Armstrong Number Checker: Write a program that will check whether the number is an Armstrong number or not.
- Narcissist Number Checker: Write a program that will take user input of a 4-digit number and check whether it is a narcissist number or not.
- In-Hand Salary Calculator: Write a program that will give you the in-hand salary after the deduction of HRA (10%), DA (5%), PF (3%), and tax:
Salary between 5-10 lakh – 10%
Salary between 11-20 lakh – 20%
Salary > 20 lakh – 30%
Salary < 1 lakh print k
- Unit Converter: Write a menu-driven program:
- cm to ft
- kl to miles
- USD to INR
- Exit
- Animal Count: Write a program that will tell the number of dogs and chickens based on the user-provided value of total heads and legs.
- Swap Numbers: Write a program to swap numbers.
- Sum of First n Numbers: Write a program to find the sum of the first n numbers, where n is provided by the user. E.g., if the user provides n=10, the output should be 55.
- Multiplication Without Operator: Write a program that can multiply two numbers provided by the user without using the
*
operator. - Factorial Calculator: Write a program that can find the factorial of a given number provided by the user.
- First 25 Odd Numbers: Write a program to print the first 25 odd numbers.
- Prime Number Checker: Write a program to check whether a given number is prime.
- Armstrong Numbers in Range: Print all Armstrong numbers in the range of 100 to 1000.
- Population Growth: The current population of a town is 10,000. The population is increasing at a rate of 10% per year. Write a program to find out the population at the end of each of the last 10 years.
- E.g., current population = 10,000:
- 10th year - 10,000
- 9th year - 9,000
- 8th year - 8,100, and so on.
- Unique Combinations: Write a program to print all unique combinations of 1, 2, 3, and 4.
- HCF Calculator: User will provide two numbers. Find the HCF of those numbers.
- LCM Calculator: User will provide two numbers. Find the LCM of those numbers.
- First 25 Prime Numbers: Print the first 25 prime numbers.
- Fibonacci Series: Print the first 20 numbers of a Fibonacci series.
- Compound Interest Calculator: Write a program to find the compound interest.
- Number Series Calculator: Write a Python program that accepts an integer
n
and computes the value ofn + nn + nnn
. - Digit Counter: Take a number from the user and find the number of digits in it.
- Factor Finder: Print all factors of a given number provided by the user.
- Reverse a Number: Find the reverse of a number provided by the user (any number of digits).
- Pattern 1:
* ** *** **** *****
- Pattern 2:
* ** *** ** *
- Pattern 3:
* * * * * * * * * * * * * * * * * * * * * * * * *
- Pattern 4:
1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1
- Pattern 5:
1 2 3 4 5 6 7 8 9 10
- Sum of Series: Write a program to calculate the sum of the following series till the nth term:
1/1! + 2/2! + 3/3! + ... + n/n!
- Another Series Sum: Write a Python program to find the sum of the series till the nth term:
1 + x^2/2 + x^3/3 + ... + x^n/n
, wheren
is provided by the user. - Natural Logarithm Series: The natural logarithm can be approximated by a series. Write a program to calculate the sum of the first seven terms of this series, where
x
is input by the user. - Sum and Average Calculator: Write a program that keeps accepting numbers from the user until the user enters zero. Display the sum and average of all the numbers.
- Fraction Simplifier: Write a program that accepts two numbers from the user—a numerator and a denominator—and then simplifies it.
- E.g., if
num = 5
,den = 15
, the answer should be⅓
. - E.g., if
num = 6
,den = 9
, the answer should be⅔
.
- E.g., if
- String Length without
len()
: Find the length of a given string without using thelen()
function. - Extract Username from Email: Extract the username from a given email.
- E.g., if the email is
[email protected]
, then the username should benitish24singh
.
- E.g., if the email is
- Character Frequency Counter: Count the frequency of a particular character in a provided string.
- E.g., in the string
'hello how are you'
, the frequency of'h'
is 2.
- E.g., in the string
- Character Position Finder: Find the index position of a particular character in another string.
- Vowel Counter: Count the number of vowels in a string provided by the user.
- Character Remover: Write a program that can remove a particular character from a string.
- Palindrome Checker: Write a program that can check whether a given string is a palindrome.
- Remove Duplicates from List: Write a Python program to remove all the duplicates from a list.
- String to Title Case without
title()
: Write a Python program to convert a string to title case without using thetitle()
function. - Max Item in List without
max()
: Write a Python program to find the max item from a list without using themax()
function. - Reverse a List: Write a Python program to reverse a list.
- Search in List: Write a Python program to search for a given number in a list.
- Square List Items: Write a program that creates a new list from a given list where each item in the new list is the square of the item in the old list.
- Reverse Words in String: Write a program that can reverse the words of a given string.
- E.g., if the input is
Hello how are you
, the output should beyou are how Hello
.
- E.g., if the input is
- Word Counter: Write a program that can count the number of words in a given string.
- Check Ascending Order: Write a program to check if a list is in ascending order or not.
- Separate Odd and Even Numbers: Create two lists from a given list where one list contains all the odd numbers and the other contains all the even numbers from the original list.
- Merge Two Lists without
+
Operator: Write a program to merge two lists without using the+
operator. - Replace Item in List: Write a program to replace an item with a different item if found in the list.
- Convert 2D List to 1D List: Write a program that can convert a 2D list to a 1D list.
- Union and Intersection of Lists: Write a program that can perform union and intersection on two given lists.
- Max Item of Each Row in Matrix: Write a program to find the max item of each row of a matrix.
- Integer to String Converter: Write a program that can convert an integer to a string.
- Matrix Shape: Write a program to print the shape of a matrix.
- Matrix Multiplication Feasibility: Write a program that can check if you can perform matrix multiplication on two matrices.
- Matrix Multiplication: Write a program to perform matrix multiplication on two matrices.
- Sort List without Built-in Function: Write a program that can sort a given unsorted list without using any built-in function for sorting.
- Most Used Word in Song: Write a program that can find the most used word in a Bollywood song.
- List to Dictionary Converter: Assume a list with numbers from 1 to 10, then convert it into a dictionary where the key is the number, and the value is the square of that number.
- Merge Two Dictionaries: Write a program to merge two given dictionaries.
- Swap Key-Value Pairs for Max and Min: Write a program to swap the key-value pair for max and min values.
- E.g., if the dict is like this:
{‘a’: 1, ‘b’: 2, ‘c’: 3}
, the output should be{a: 3, b: 2, c: 1}
.
- E.g., if the dict is like this:
- Histogram Generator: Write a program to find a histogram of a given set of numbers. Take the bin size from the user and print the result as a dictionary.
- Case Count in String: Write a function that accepts a string and returns the number of uppercase and lowercase characters as a dictionary.
- Bag of Words: Write a function that accepts a list of strings and performs Bag of Words, converting it to numerical vectors.
- Login and Registration: Write a dummy program that can perform login and registration using a menu-driven interface.
- Nearest Neighbor: Write a program that accepts neighbors (a set of 2D coordinates) and a point (a single 2D coordinate) and tells the nearest neighbor (in terms of Euclidean distance).
- Recursive Factorial Function: Write a function that accepts a number and returns its factorial. You cannot use any loop.
Happy coding! 🎉
Course Resources : click here