Python Tutorials · Python Examples

Python Practice Problems

Learn all about Python Practice Problems in this comprehensive tutorial.

5 min read beginner
  • Improve your skills by solving real Python coding problems.
  • Each challenge gives you starter code in Python.

Introduction

Improve your skills by solving real Python coding problems.

Write code, submit, and get instant feedback.

More Practice Problems

ProblemDescriptionDifficultyXP
Say HelloRead a name from input and print a greeting.Easy20 XP
Celsius to FahrenheitConvert a temperature from Celsius to Fahrenheit.Easy20 XP
Even or OddCheck if a number is even or odd.Easy20 XP
Make a UsernameCreate a username and initials from a first and last name.Easy20 XP
Voting AgeDetermine if a person is old enough to vote.Easy20 XP
Grade CalculatorConvert a score into a letter grade.Easy20 XP
Multiplication TablePrint the multiplication table for a given number.Easy20 XP
FactorialCreate a function that calculates the factorial of a number.Easy20 XP
Sum of NumbersRead a list of numbers and calculate their sum.Easy20 XP
Area CalculatorCalculate the area of a rectangle, triangle, or circle.Easy20 XP
Shopping ReceiptRead item details from input and print a short receipt.Easy20 XP
Personal InfoRead personal details from input and display them.Easy20 XP
Swap ValuesRead two values and print them in swapped order.Easy20 XP
Rectangle BorderPrint a rectangle border made of stars.Easy20 XP
Repeat MessageRead a message and a number, then print the message that many times.Easy20 XP
Currency ExchangeCalculate a currency exchange from an amount and rate.Easy20 XP
BMI CalculatorCalculate Body Mass Index from weight and height.Easy20 XP
Circle PropertiesCalculate the circumference and area of a circle.Easy20 XP
Simple CalculatorPerform basic arithmetic on two numbers.Easy20 XP
Discount PriceCalculate a discounted price from a price and discount percentage.Easy20 XP
Split the BillSplit a total amount equally among a group of people.Easy20 XP
Digit ExtractorExtract the individual digits of a 3-digit number.Easy20 XP
Word CounterCount the number of words in a sentence.Easy20 XP
Shout It OutConvert a string to uppercase and print its length.Easy20 XP
First and LastPrint the first and last character of a word.Easy20 XP
Repeat StringRead a string and a number, then print the string repeated that many times.Easy20 XP
Range CheckerCheck if a number falls within a given range.Easy20 XP
Password CheckCheck if a password is long enough.Easy20 XP
Ticket PriceDetermine the ticket type and price based on age.Easy20 XP
Positive Negative ZeroCheck if a number is positive, negative, or zero.Easy20 XP
Smallest of ThreeFind the smallest of three numbers.Easy20 XP
CountdownCount down from a number to 1 and print Go!Easy20 XP
FizzBuzzImplement the classic FizzBuzz challenge.Easy20 XP
Sum 1 to NCalculate the sum of all numbers from 1 to N.Easy20 XP
Star TrianglePrint a right triangle made of stars.Easy20 XP
Tip CalculatorCreate a tip calculator function for a restaurant bill.Easy20 XP
Power FunctionWrite a function that calculates the power of a number.Easy20 XP
Average ScoreRead a list of scores and calculate their average.Easy20 XP
Count MatchesCount how many numbers in a list match a target value.Easy20 XP
Min and MaxFind the smallest and largest numbers in a list.Easy20 XP
Absolute DifferenceCalculate the absolute difference between two numbers.Easy20 XP
Round Up or DownRound a decimal number to the nearest whole number.Easy20 XP
Leap YearDetermine if a given year is a leap year.Medium50 XP
Day of WeekConvert a day number to a day name.Medium50 XP
Triangle ClassifierClassify a triangle based on its side lengths.Medium50 XP
Time ConverterConvert a number of seconds into hours, minutes, and seconds.Medium50 XP
Reverse WordsReverse the order of words in a sentence.Medium50 XP
Palindrome CheckCheck if a word reads the same forwards and backwards.Medium50 XP
Count VowelsCount the number of vowels in a string.Medium50 XP
Title CaseCapitalize the first letter of each word in a sentence.Medium50 XP
Remove DuplicatesRemove consecutive duplicate characters from a string.Medium50 XP
Longest WordFind the longest word in a sentence.Medium50 XP
Access ControlDetermine if a person gets access based on role, age, and membership.Medium50 XP
Digit SumCalculate the sum of all digits in a number.Medium50 XP
Number PyramidPrint a pyramid of numbers.Medium50 XP
Collatz StepsCount the steps to reach 1 using the Collatz sequence.Medium50 XP
Prime CheckCheck if a number is a prime number.Medium50 XP
Reverse NumberReverse the digits of a number.Medium50 XP
Is Palindrome FunctionWrite a function that checks if a word is a palindrome.Medium50 XP
Min of ThreeWrite a function that returns the smallest of three numbers.Medium50 XP
Count DigitsWrite a function that counts the number of digits in a number.Medium50 XP
Recursive SumWrite a recursive function to sum numbers from 1 to N.Medium50 XP
Array Map FunctionWrite a function that doubles every number in a list.Medium50 XP
Find the LargestRead a list of numbers and find the largest one.Medium50 XP
Reverse a ListRead a list of numbers and print them in reverse order.Medium50 XP
Second LargestFind the second largest number in a list.Medium50 XP
Running SumPrint the running (cumulative) sum of a list of numbers.Medium50 XP
Count Above AverageCount how many numbers are above the average.Medium50 XP
Longest StreakFind the longest consecutive streak of the same number.Medium50 XP
Greatest Common DivisorFind the greatest common divisor (GCD) of two numbers.Medium50 XP
FibonacciPrint the first N numbers of the Fibonacci sequence.Medium50 XP
Prime FactorsFind all prime factors of a number.Medium50 XP
Power of TwoCheck if a number is a power of 2.Medium50 XP
Sum of SquaresCalculate the sum of squares from 1 to N.Medium50 XP
LCM CalculatorCalculate the least common multiple of two numbers.Medium50 XP
Perfect NumberCheck if a number is a perfect number.Medium50 XP
Sort Three NumbersRead three numbers and print them in ascending order.Medium50 XP
Sort NumbersRead a list of numbers and print them sorted.Medium50 XP
Sort WordsRead a list of words and print them sorted alphabetically.Medium50 XP
Letter FrequencyCount how many times each letter appears in a word.Medium50 XP
Most Common CharFind the character that appears most often in a string.Medium50 XP
Digit FrequencyCount how many times each digit appears in a number.Medium50 XP
Caesar CipherEncrypt a message by shifting each letter in the alphabet.Hard100 XP
Anagram CheckCheck if two words are anagrams of each other.Hard100 XP
Run Length EncodingCompress a string using run-length encoding.Hard100 XP
Date ValidatorCheck if a given date is valid.Hard100 XP
Diamond PatternPrint a diamond pattern of stars.Hard100 XP
Number to BinaryConvert a decimal number to binary.Hard100 XP
Pascal Triangle RowPrint a specific row of Pascal's triangle.Hard100 XP
Remove DuplicatesRemove duplicate numbers from a list while keeping order.Hard100 XP
Rotate LeftRotate a list of numbers to the left by K positions.Hard100 XP
Merge SortedMerge two sorted lists into one sorted list.Hard100 XP
Pair SumFind the first pair of numbers that add up to a target.Hard100 XP
GCD FunctionWrite a recursive function to find the GCD of two numbers.Hard100 XP
Number Base ConvertConvert a number from one base to another.Hard100 XP
Bubble SortImplement bubble sort and count the number of swaps.Hard100 XP
Selection SortImplement selection sort and print each step.Hard100 XP
Insertion SortImplement insertion sort and print each step.Hard100 XP
Word FrequencyCount how many times each word appears in a sentence.Hard100 XP
Unique Elements CountCount how many unique numbers appear in a list.Hard100 XP

Past Weekly Challenges

ProblemDescriptionDifficultyXP
Double or NothingDouble a number if it is positive, otherwise print zero.Easy20 XP
Balanced BracketsCheck if a string of brackets is balanced.Medium50 XP
Matrix Diagonal SumCalculate the sum of both diagonals of a square matrix.Hard100 XP
Sum of DigitsCalculate the sum of all digits in a given number.Easy20 XP
Find the DuplicateFind the duplicate number in an array of integers.Medium50 XP
Maximum Subarray SumFind the contiguous subarray with the largest sum.Hard100 XP
Reverse StringReverse a string without using built-in reverse functions.Easy20 XP
Count ConsonantsCount the number of consonants in a string.Medium50 XP
Sum of PrimesFind the sum of all prime numbers up to N using a sieve.Hard100 XP

How it Works

Each challenge gives you starter code in Python. Your program reads input and prints the correct output.

When you submit, your code is tested against multiple hidden test cases with different inputs.

Your score is based on how many tests pass — partial credit is given for partially correct solutions.

Module quiz

2 questions
1

Which of the following is true about Python Practice Problems?

2

What is the most common pitfall when working with Python Practice Problems?

Answer all questions to submit.