Python tasks
Every task in one place. Pick a mode, a topic or a concept to practise.
Exam-style tasks. Each shows the concepts it needs - review them first if you like.
63 tasks
- Write a programBasicDigit sumGraduation exam preparation · StringsConverting types: int(), float(), str()Counting and summing in a loopLooping over a string
- Write a programBasicHalf pyramidGraduation exam preparation · StringsInput with input()for loops and range()Slicing
- Write a programElementaryBMI calculatorGraduation exam preparation · StringsReading numbers from inputFormatting output: sep, end, f-stringsArithmetic operatorsSeveral branches: elif
- Write a programBasicFinding a characterGraduation exam preparation · StringsInput with input()String methods: upper, find, replace, …
- Small projectIntermediateBirth numberGraduation exam preparation · StringsConverting types: int(), float(), str()Integer division and remainder: // and %The if statementSlicingString methods: upper, find, replace, …
- Write a programElementaryThe Fibonacci sequenceGraduation exam preparation · StringsVariables and assignmentReading numbers from inputfor loops and range()
- Write a programIntermediateMind readerGraduation exam preparation · StringsReading numbers from inputInteger division and remainder: // and %while loopsReturn values: returntry – except
- Algorithmic problemElementaryGreatest common divisorGraduation exam preparation · StringsInteger division and remainder: // and %while loopsDivisibility, primes, GCD
- Write a programElementaryA number inside a random numberGraduation exam preparation · StringsConverting types: int(), float(), str()Return values: returnString methods: upper, find, replace, …Standard modules: math, random
- Write a programElementaryCaesar cipherGraduation exam preparation · StringsInteger division and remainder: // and %Several branches: elifLooping over a stringCharacters and codes: ord() and chr()
- Write a programBasicPalindromeGraduation exam preparation · StringsTwo branches: if – elseSlicingString methods: upper, find, replace, …
- Write a programElementaryCharacters and wordsGraduation exam preparation · StringsString methods: upper, find, replace, …Splitting and joining: split() and join()len, sum, min, max and sorted
- Write a programElementaryQuadratic equationGraduation exam preparation · StringsReading numbers from inputArithmetic operatorsSeveral branches: elifStandard modules: math, random
- Small projectElementaryRock, paper, scissorsGraduation exam preparation · StringsLogical operators: and, or, notSeveral branches: elifReturn values: returnStandard modules: math, random
- Write a programElementaryPassword checkGraduation exam preparation · StringsLogical operators: and, or, notThe if statementLooping over a stringString methods: upper, find, replace, …
- Predict the outputElementaryString slicesGraduation exam preparation · StringsIndexing charactersSlicing
- Write a programElementaryElements that occur only onceGraduation exam preparation · ListsReturn values: returnList methods: append, pop, remove, …Looping over a listStandard modules: math, random
- Small projectIntermediateShopping basketGraduation exam preparation · ListsFormatting output: sep, end, f-stringswhile loopsList methods: append, pop, remove, …len, sum, min, max and sorted
- Write a programElementarySki jumpersGraduation exam preparation · ListsFormatting output: sep, end, f-stringsReturn values: returnLooping over a listlen, sum, min, max and sorted
- Write a programBasicFibonacci into a listGraduation exam preparation · Listsfor loops and range()Creating lists and indexingList methods: append, pop, remove, …
- Write a programElementaryEven and odd, sortedGraduation exam preparation · ListsInteger division and remainder: // and %while loopsList methods: append, pop, remove, …len, sum, min, max and sorted
- Write a programBasicA random list reversedGraduation exam preparation · ListsReturn values: returnSlicingLooping over a listStandard modules: math, random
- Write a programBasicSum of even numbersGraduation exam preparation · ListsInteger division and remainder: // and %Counting and summing in a loopReturn values: returnLooping over a list
- Write a programElementaryThe second largest numberGraduation exam preparation · ListsList methods: append, pop, remove, …len, sum, min, max and sortedSets and unique itemsFinding the minimum and maximum
- Write a programElementaryVowel or consonantGraduation exam preparation · ListsSeveral branches: elifwhile loopsString methods: upper, find, replace, …Membership: in
- Write a programElementaryGuest namesGraduation exam preparation · Listswhile loopsString methods: upper, find, replace, …Splitting and joining: split() and join()List methods: append, pop, remove, …
- Write a programElementaryCommon elements of two listsGraduation exam preparation · ListsReturn values: returnList methods: append, pop, remove, …Looping over a listMembership: in
- Write a programBasicEntered values reversedGraduation exam preparation · ListsReading numbers from inputwhile loopsSlicingList methods: append, pop, remove, …
- Write a programBasicThe largest and the smallest numberGraduation exam preparation · Listswhile loopsList methods: append, pop, remove, …len, sum, min, max and sortedFinding the minimum and maximum
- Write a programElementaryThe most frequent elementGraduation exam preparation · ListsSplitting and joining: split() and join()List methods: append, pop, remove, …len, sum, min, max and sortedFinding the minimum and maximum
- Find the bugElementaryAn average that is offGraduation exam preparation · ListsCounting and summing in a loopLooping over a listlen, sum, min, max and sorted
- Write a programElementaryTime in secondsGraduation exam preparation · The while loopReading numbers from inputFormatting output: sep, end, f-stringsInteger division and remainder: // and %while loops
- Write a programBasicGuess the wordGraduation exam preparation · The while loopInput with input()The if statementwhile loopsString methods: upper, find, replace, …
- Write a programBasicNumbers without 3, 7 and 14Graduation exam preparation · The while loopReading numbers from inputLogical operators: and, or, notThe if statementwhile loops
- Write a programBasicEven numbers up to a limitGraduation exam preparation · The while loopReading numbers from inputwhile loops
- Write a programBasicCharacters and their positionsGraduation exam preparation · The while loopInput with input()while loopsIndexing characters
- Write a programBasicCounting down to 5Graduation exam preparation · The while loopReading numbers from inputThe if statementwhile loops
- Write a programBasicOdd numbers except 17Graduation exam preparation · The while loopComparisons: ==, !=, <, >=The if statementwhile loops
- Algorithmic problemElementaryThe Collatz sequenceGraduation exam preparation · The while loopReading numbers from inputInteger division and remainder: // and %Two branches: if – elsewhile loops
- Algorithmic problemElementaryTo binaryGraduation exam preparation · The while loopText: the str typeReading numbers from inputInteger division and remainder: // and %while loops
- Write a programElementaryLotteryGraduation exam preparation · Mixed taskswhile loopsReturn values: returnList methods: append, pop, remove, …Standard modules: math, random
- Write a programElementaryPrime numbersGraduation exam preparation · Mixed tasksInteger division and remainder: // and %while loopsReturn values: returnDivisibility, primes, GCD
- Write a programElementaryMinimum, count and positionsGraduation exam preparation · Mixed tasksReturn values: returnLooping over a listlen, sum, min, max and sortedFinding the minimum and maximum
- Write a programElementaryTest scoresGraduation exam preparation · Mixed tasksFormatting output: sep, end, f-stringswhile loopsList methods: append, pop, remove, …len, sum, min, max and sortedtry – except
- Write a programElementaryPerfect numbersGraduation exam preparation · Mixed tasksInteger division and remainder: // and %for loops and range()Return values: returnDivisibility, primes, GCD
- Write a programBasicCoin tossGraduation exam preparation · Mixed tasksfor loops and range()Counting and summing in a loopReturn values: returnStandard modules: math, random
- Write a programBasicTrain passengersGraduation exam preparation · Mixed tasksReading numbers from inputThe if statementwhile loopsCounting and summing in a loop
- Write a programBasicLeap yearGraduation exam preparation · Mixed tasksReading numbers from inputInteger division and remainder: // and %Logical operators: and, or, notTwo branches: if – else
- Fix the programElementaryFix the prime testGraduation exam preparation · Mixed tasksInteger division and remainder: // and %The if statementfor loops and range()Divisibility, primes, GCD
- Small projectElementaryA tuft of grassGraduation exam preparation · Graphics with tkinterfor loops and range()Standard modules: math, randomDrawing on a canvas (tkinter)Events: clicks and keys
- Write a programElementaryA colour-changing squareGraduation exam preparation · Graphics with tkinterDefining and calling functionsStandard modules: math, randomDrawing on a canvas (tkinter)Animation: after()
- Write a programElementaryA text windmillGraduation exam preparation · Graphics with tkinterInput with input()for loops and range()Drawing on a canvas (tkinter)
- Small projectIntermediateScreensaverGraduation exam preparation · Graphics with tkinterStandard modules: math, randomDrawing on a canvas (tkinter)Animation: after()Buttons and entry fields
- Small projectElementaryA row of squaresGraduation exam preparation · Graphics with tkinterfor loops and range()Drawing on a canvas (tkinter)Animation: after()
- Write a programBasicA little houseGraduation exam preparation · Graphics with tkinterDrawing on a canvas (tkinter)
- Write a programBasicCircles by clickingGraduation exam preparation · Graphics with tkinterDefining and calling functionsDrawing on a canvas (tkinter)Events: clicks and keys
- Write a programElementaryColoured raysGraduation exam preparation · Graphics with tkinterSeveral branches: elifDefining and calling functionsDrawing on a canvas (tkinter)Events: clicks and keys
- Write a programBasicA numeric passwordGraduation exam preparation · Exceptions (try – except)while loopsbreak and continuetry – exceptValidating input
- Small projectElementaryGuess a number from 1 to 50Graduation exam preparation · Exceptions (try – except)Several branches: elifwhile loopstry – exceptValidating inputStandard modules: math, random
- Write a programElementaryA bounded Fibonacci sequenceGraduation exam preparation · Exceptions (try – except)Reading numbers from inputwhile loopsList methods: append, pop, remove, …try – except
- Write a programElementaryIs the number divisible?Graduation exam preparation · Exceptions (try – except)Integer division and remainder: // and %Splitting and joining: split() and join()try – exceptKinds of exceptions: ValueError, ZeroDivisionError, …
- Write a programElementaryA safe averageGraduation exam preparation · Exceptions (try – except)while loopslen, sum, min, max and sortedtry – exceptKinds of exceptions: ValueError, ZeroDivisionError, …
- Predict the outputIntermediatetry, except, else, finallyGraduation exam preparation · Exceptions (try – except)Return values: returntry – exceptKinds of exceptions: ValueError, ZeroDivisionError, …