Python tasks
Every task in one place. Pick a mode, a topic or a concept to practise.
Short understanding tasks: multiple choice, predicting the output, finding the bug and completing code.
123 tasks
- Multiple choiceBasicPrinting textProgramming basics · Theory and practicePrinting with print()
- Predict the outputBasicStatements run in orderProgramming basics · Theory and practicePrograms and how they runPrinting with print()
- True / falseBasicA commentProgramming basics · Theory and practiceComments
- Predict the outputBasicCommas and pluses in printProgramming basics · Theory and practicePrinting with print()
- Code comprehensionBasicWhy an error?Programming basics · Theory and practicePrinting with print()Error messages
- Fix the programBasicFix the outputProgramming basics · Theory and practicePrinting with print()Error messages
- Predict the outputBasicA variable changesVariables and data types · Theory and practiceVariables and assignmentArithmetic operators
- Multiple choiceBasicWhich type is it?Variables and data types · Theory and practiceNumbers: int and float
- Predict the outputElementaryText or number?Variables and data types · Theory and practiceNumbers: int and floatText: the str type
- True / falseBasicThe result of a comparisonVariables and data types · Theory and practiceTruth values: boolComparisons: ==, !=, <, >=
- Find the bugElementaryText and a number togetherVariables and data types · Theory and practiceText: the str typeConverting types: int(), float(), str()
- Complete the codeBasicFrom text to a numberVariables and data types · Theory and practiceConverting types: int(), float(), str()
- Multiple choiceBasicWhat does input() return?Input and output · Theory and practiceText: the str typeInput with input()
- Predict the outputBasicsep and endInput and output · Theory and practiceFormatting output: sep, end, f-strings
- Predict the outputElementaryAn f-stringInput and output · Theory and practiceFormatting output: sep, end, f-stringsArithmetic operators
- True / falseBasicA sum from input?Input and output · Theory and practiceInput with input()Reading numbers from input
- Multiple choiceElementaryRoundingInput and output · Theory and practiceFormatting output: sep, end, f-strings
- Fix the programElementaryThe area of a rectangleInput and output · Theory and practiceReading numbers from inputArithmetic operators
- Predict the outputBasicThree kinds of divisionOperators · Theory and practiceArithmetic operatorsInteger division and remainder: // and %
- Multiple choiceBasicWhat is computed first?Operators · Theory and practiceArithmetic operators
- Predict the outputElementaryPowers and the minus signOperators · Theory and practiceArithmetic operators
- True / falseBasicBoth conditions at onceOperators · Theory and practiceComparisons: ==, !=, <, >=Logical operators: and, or, not
- Complete the codeElementaryIs the number even?Operators · Theory and practiceReading numbers from inputInteger division and remainder: // and %Comparisons: ==, !=, <, >=
- Predict the outputBasicAugmented assignmentOperators · Theory and practiceAugmented assignment: +=, -=
- Predict the outputElementaryWhich branch runs?Conditions · Theory and practiceComparisons: ==, !=, <, >=Several branches: elif
- Multiple choiceBasicWhat belongs to a branch?Conditions · Theory and practiceThe if statement
- True / falseBasicThe else branchConditions · Theory and practiceTwo branches: if – else
- Find the bugBasicA comparison in a conditionConditions · Theory and practiceComparisons: ==, !=, <, >=The if statement
- Predict the outputElementaryA condition inside a conditionConditions · Theory and practiceInteger division and remainder: // and %Nested conditions
- Fix the programElementaryPositive, negative or zeroConditions · Theory and practiceReading numbers from inputTwo branches: if – elseSeveral branches: elif
- Multiple choiceBasicrange with a stepLoops · Theory and practicefor loops and range()
- Predict the outputBasicWhile the condition holdsLoops · Theory and practicewhile loops
- Predict the outputElementaryEnding a loop earlyLoops · Theory and practiceThe if statementfor loops and range()break and continue
- True / falseBasicHow many times?Loops · Theory and practicefor loops and range()
- Predict the outputElementaryA loop inside a loopLoops · Theory and practicefor loops and range()Nested loops
- Find the bugElementaryA loop that never endsLoops · Theory and practicewhile loops
- Complete the codeElementaryThe sum from 1 to nLoops · Theory and practiceReading numbers from inputfor loops and range()Counting and summing in a loop
- Predict the outputBasicWhat the function returnsFunctions · Theory and practiceDefining and calling functionsReturn values: return
- Predict the outputElementaryA function without returnFunctions · Theory and practiceParameters and argumentsReturn values: return
- Multiple choiceBasicThe return statementFunctions · Theory and practiceReturn values: return
- True / falseBasicTwo parametersFunctions · Theory and practiceParameters and argumentsReturn values: return
- Predict the outputElementaryA variable inside a functionFunctions · Theory and practiceLocal and global variables
- Find the bugBasicA forgotten callFunctions · Theory and practiceDefining and calling functionsParameters and arguments
- Complete the codeElementaryThe larger of two numbersFunctions · Theory and practiceThe if statementParameters and argumentsReturn values: return
- Multiple choiceBasicCharacters at positionsStrings · Theory and practiceIndexing characters
- Predict the outputElementaryString slicesStrings · Theory and practiceSlicing
- Predict the outputBasicString methodsStrings · Theory and practiceString methods: upper, find, replace, …
- True / falseElementaryChanging a characterStrings · Theory and practiceIndexing characters
- Predict the outputBasicSplit and joinStrings · Theory and practiceSplitting and joining: split() and join()
- Complete the codeElementaryHow many letters a?Strings · Theory and practiceCounting and summing in a loopLooping over a string
- Multiple choiceElementaryThe next letterStrings · Theory and practiceCharacters and codes: ord() and chr()
- Predict the outputBasicAdding to a listLists · Theory and practiceList methods: append, pop, remove, …len, sum, min, max and sorted
- Multiple choiceBasicElements by indexLists · Theory and practiceCreating lists and indexing
- Predict the outputBasicSum, maximum, minimumLists · Theory and practicelen, sum, min, max and sorted
- True / falseElementaryTwo names, one listLists · Theory and practiceCreating lists and indexingList methods: append, pop, remove, …
- Predict the outputElementaryA list in one lineLists · Theory and practiceInteger division and remainder: // and %List comprehensions
- Find the bugElementaryA missing elementLists · Theory and practicefor loops and range()Looping over a list
- Complete the codeElementaryEven numbers onlyLists · Theory and practiceReturn values: returnList methods: append, pop, remove, …Looping over a list
- Predict the outputBasicUnpacking a tupleTuples · Theory and practiceUnpacking: a, b = …
- True / falseBasicChanging a tupleTuples · Theory and practiceTuples and immutability
- Multiple choiceElementaryA one-element tupleTuples · Theory and practiceTuples and immutability
- Predict the outputBasicSwapping valuesTuples · Theory and practiceUnpacking: a, b = …
- Predict the outputElementaryA function returns two valuesTuples · Theory and practiceReturn values: returnReturning several values
- Complete the codeElementaryQuotient and remainder at onceTuples · Theory and practiceInteger division and remainder: // and %Return values: returnReturning several values
- Predict the outputBasicNo repeatsSets · Theory and practiceSets and unique items
- Multiple choiceBasicCommon elementsSets · Theory and practiceUnion, intersection, difference
- True / falseBasicIs it in the set?Sets · Theory and practiceMembership: in
- Predict the outputElementaryDifference and unionSets · Theory and practicelen, sum, min, max and sortedUnion, intersection, difference
- Multiple choiceElementaryAn empty setSets · Theory and practiceSets and unique items
- Complete the codeElementaryThe number of different wordsSets · Theory and practiceSplitting and joining: split() and join()Sets and unique items
- Predict the outputBasicKeys and valuesDictionaries · Theory and practiceKeys and values
- Multiple choiceElementarySafe lookupDictionaries · Theory and practiceKeys and values
- True / falseBasicA missing keyDictionaries · Theory and practiceKeys and values
- Predict the outputElementaryLooping over pairsDictionaries · Theory and practiceLooping over a dictionary: keys, values, items
- Predict the outputElementaryCounting lettersDictionaries · Theory and practiceLooping over a stringCounting occurrences
- Complete the codeElementaryHow often each word appearsDictionaries · Theory and practiceReturn values: returnCounting occurrences
- Find the bugElementaryThe maximum of negative numbersAlgorithms · Theory and practiceFinding the minimum and maximum
- Multiple choiceElementaryHow many steps?Algorithms · Theory and practiceBinary search
- True / falseBasicWhat binary search needsAlgorithms · Theory and practiceBinary search
- Predict the outputElementaryEuclid's algorithmAlgorithms · Theory and practicewhile loopsUnpacking: a, b = …Divisibility, primes, GCD
- Predict the outputIntermediateOne pass of bubble sortAlgorithms · Theory and practiceUnpacking: a, b = …Sorting
- Complete the codeElementaryWhere is the value?Algorithms · Theory and practiceReturn values: returnLinear search
- Code comprehensionElementaryA prime testAlgorithms · Theory and practiceReturn values: returnDivisibility, primes, GCD
- Predict the outputElementaryWrite, then readWorking with files · Theory and practiceReading from a fileWriting to a fileThe with statement
- Multiple choiceBasicMode "w"Working with files · Theory and practiceWriting to a file
- True / falseBasicThe with blockWorking with files · Theory and practiceThe with statement
- Predict the outputElementaryAppendingWorking with files · Theory and practiceReading from a fileWriting to a file
- Find the bugElementaryAn invisible characterWorking with files · Theory and practiceReading from a fileProcessing a file line by line
- Complete the codeElementarySumming numbers from a fileWorking with files · Theory and practiceConverting types: int(), float(), str()Reading from a fileProcessing a file line by line
- Predict the outputBasicA caught errorExceptions · Theory and practicetry – except
- Multiple choiceBasicWhich exception?Exceptions · Theory and practiceKinds of exceptions: ValueError, ZeroDivisionError, …
- Multiple choiceElementaryOutside the listExceptions · Theory and practiceCreating lists and indexingKinds of exceptions: ValueError, ZeroDivisionError, …
- Predict the outputElementaryRaising an exceptionExceptions · Theory and practicetry – exceptRaising an exception: raise
- True / falseBasicWhat is skipped?Exceptions · Theory and practicetry – except
- Complete the codeElementaryA safe conversion to a numberExceptions · Theory and practicetry – exceptKinds of exceptions: ValueError, ZeroDivisionError, …Validating input
- Predict the outputBasicThe math moduleModular programs · Theory and practiceImporting modulesStandard modules: math, random
- Multiple choiceElementaryfrom … importModular programs · Theory and practiceImporting modules
- True / falseBasicA random whole numberModular programs · Theory and practiceStandard modules: math, random
- Find the bugBasicA name from a moduleModular programs · Theory and practiceImporting modulesStandard modules: math, random
- Code comprehensionBasicWho does whatModular programs · Theory and practiceSplitting a program into functions
- Complete the codeElementaryA dieModular programs · Theory and practiceReturn values: returnImporting modulesStandard modules: math, random
- Predict the outputBasicFactorialRecursion · Theory and practiceRecursive functionsThe base case
- Multiple choiceBasicWhy a base caseRecursion · Theory and practiceThe base case
- Predict the outputIntermediateBefore and after the callRecursion · Theory and practiceHow recursion unfolds
- True / falseElementaryRecursion without an endRecursion · Theory and practiceThe base case
- Find the bugElementaryThe digit sumRecursion · Theory and practiceInteger division and remainder: // and %Recursive algorithms
- Complete the codeElementaryA recursive powerRecursion · Theory and practiceRecursive functionsThe base case
- Predict the outputBasicRows and columnsAdvanced data structures · Theory and practiceTwo-dimensional lists
- Multiple choiceBasicA stackAdvanced data structures · Theory and practiceStacks and queues
- True / falseBasicA queueAdvanced data structures · Theory and practiceStacks and queues
- Predict the outputElementaryA list of dictionariesAdvanced data structures · Theory and practiceKeys and valuesLists of dictionaries and nested structures
- Predict the outputIntermediateCareful with multiplying a listAdvanced data structures · Theory and practiceCreating lists and indexingTwo-dimensional lists
- Complete the codeElementaryThe sum of all elementsAdvanced data structures · Theory and practiceNested loopsTwo-dimensional lists
- Multiple choiceElementaryAn edge caseAlgorithmic problems · Theory and practiceEdge cases
- Multiple choiceElementaryFast lookupAlgorithmic problems · Theory and practiceMembership: inEfficiency of a solution
- Predict the outputBasicA day-by-day simulationAlgorithmic problems · Theory and practicefor loops and range()Simulation
- True / falseBasicThe minimum of nothingAlgorithmic problems · Theory and practicelen, sum, min, max and sortedEdge cases
- Predict the outputElementaryHow many times can you halve itAlgorithmic problems · Theory and practicewhile loopsEfficiency of a solution
- Fix the programIntermediateThe second largest valueAlgorithmic problems · Theory and practiceSets and unique itemsSortingEdge cases
- Predict the outputElementaryString slicesGraduation exam preparation · StringsIndexing charactersSlicing
- Find the bugElementaryAn average that is offGraduation exam preparation · ListsCounting and summing in a loopLooping over a listlen, sum, min, max and sorted
- Fix the programElementaryFix the prime testGraduation exam preparation · Mixed tasksInteger division and remainder: // and %The if statementfor loops and range()Divisibility, primes, GCD
- Predict the outputIntermediatetry, except, else, finallyGraduation exam preparation · Exceptions (try – except)Return values: returntry – exceptKinds of exceptions: ValueError, ZeroDivisionError, …