Python practice tasks
Read input, trace output, put programs in order, write tests, answer questions about data and draw pictures.
Programs with input
- Total Runs in an OverSix balls of cricket, one total for the overBeginner · 5 min
- Total and Percentage of MarksFive subjects in, a total and a percentage outBeginner · 5 min
- Area and Circumference of a CircleOne radius, two answers about a circleBeginner · 5 min
- Simple InterestHow much interest a bank deposit earns over the yearsBeginner · 5 min
- Celsius to FahrenheitTurn a Celsius reading into FahrenheitBeginner · 4 min
- Grade From MarksTurn marks out of 100 into a letter gradeBeginner · 5 min
- Even or OddDecide whether a whole number is even or oddBeginner · 3 min
- Largest of Three NumbersPick the biggest of three numbersBeginner · 4 min
- Leap Year CheckFind out whether a year has 29 days in FebruaryBeginner · 5 min
- Count the VowelsCount the vowels in a word or a sentenceBeginner · 5 min
- Reverse a NumberTurn a number's digits back to frontBeginner · 6 min
- Multiplication TablePrint the times table for any numberBeginner · 4 min
- Menu CalculatorA four-choice calculator driven by a menuIntermediate · 8 min
- Add Numbers Until ZeroKeep reading quiz points until a zero ends the listIntermediate · 8 min
- Count and Add the DigitsHow many digits a number has, and what they add up toIntermediate · 7 min
- Words in a SentenceCount the words in a sentence and find the longestIntermediate · 7 min
- Prime or NotDecide whether a number is primeIntermediate · 7 min
- Factorial of a NumberMultiply all the whole numbers from 1 up to nIntermediate · 6 min
- Sum of a Power SeriesAdd up the powers of a number, term by termIntermediate · 8 min
- Palindrome NumberNumbers that read the same in both directionsIntermediate · 7 min
- Armstrong NumberNumbers equal to the sum of their own digits' powersIntermediate · 8 min
- How Often Each Letter AppearsCount how many times each letter turns up in a wordIntermediate · 8 min
- Marks on One LineA whole line of marks, summed up in four linesIntermediate · 8 min
- Shop Bill With a DiscountA shop bill where bigger totals earn bigger discountsIntermediate · 9 min
- Row and Column Sums of a MatrixRead a grid of numbers and add it up every wayAdvanced · 15 min
- Class Marks ReportNames and marks in, a full class report outAdvanced · 18 min
- Bank Account MenuDeposits, withdrawals and balances from a menu loopAdvanced · 20 min
- Diamond of StarsA centered diamond of stars from one numberAdvanced · 15 min
- Decimal to Binary and Other BasesWrite a number in binary, octal, hex or any base up to 16Advanced · 15 min
- Tic-Tac-Toe ResultRead a board and say who won, if anyoneAdvanced · 18 min
What does this print?
- Python Basics: What Does This PrintTypes, conversions and printBeginner · 6 min
- Operators: What Does This PrintDivision, remainders, powers and the order of operationsBeginner · 6 min
- Strings: What Does This PrintIndexes, slices, methods and text that cannot changeBeginner · 6 min
- Conditionals: What Does This Printif, elif, else, truthy values and matchBeginner · 6 min
- Loops: What Does This Printrange, break, continue and loop countersBeginner · 6 min
- Lists: What Does This Printappend, extend, copies, slices and sortBeginner · 6 min
- Tuples: What Does This PrintOne-item tuples, unpacking and tuples that hold listsIntermediate · 8 min
- Dictionaries: What Does This PrintKeys, get, pop, setdefault and countingIntermediate · 8 min
- Sets: What Does This PrintDuplicates, set operations and empty bracesIntermediate · 8 min
- Comprehensions: What Does This PrintList, dict and set comprehensions and generatorsIntermediate · 8 min
- Functions: What Does This PrintReturn values, defaults, scope and recursionIntermediate · 8 min
- Lambda, Map and Filter: What Does This Printlambda, map, filter, sorted with a key, any and allIntermediate · 8 min
- Exceptions: What Does This PrintWhich of try, except, else and finally runs, and whenAdvanced · 10 min
- Classes and Objects: What Does This PrintClass and instance attributes, inheritance and special methodsAdvanced · 10 min
- Tricky Python: What Does This PrintMutable defaults, late binding, aliasing and other gotchasAdvanced · 10 min
Rearrange the lines
- Your First ProgramGreet a friend and work out an ageBeginner · 3 min
- Swap Two ValuesTrade the values of two variablesBeginner · 3 min
- Cinema BillAdd up tickets and snacks for a cinema tripBeginner · 3 min
- Add Up the Even NumbersCount and add the even numbers up to 20Beginner · 4 min
- Grades for Four StudentsMarks in, letter grades out, for four studentsBeginner · 4 min
- Rocket CountdownCount down from 5 before the launchBeginner · 3 min
- Growing PlantWatch a plant grow week by weekBeginner · 4 min
- Canteen QueueJoin, push in and serve a lunch queueBeginner · 4 min
- Hot Days in a WeekPick out the hot days from a week of readingsBeginner · 4 min
- A Word BackwardsBuild a word back to front, letter by letterBeginner · 4 min
- A Function for Sale PricesWrite a function once, use it twiceIntermediate · 5 min
- Triangle of StarsRows of stars that grow by one each timeIntermediate · 5 min
- Counting Class VotesTally a class vote for the sports day T-shirt colorIntermediate · 6 min
- Skip What Is Not a NumberAdd up a list where some entries are not whole numbersIntermediate · 6 min
- Highest Score From InputRead some scores and keep the best oneIntermediate · 6 min
- Primes With a Helper FunctionA helper function that finds the primes under 30Intermediate · 8 min
- Guess the NumberKeep guessing until the secret number turns upIntermediate · 6 min
- A Bank Account ClassAn account that pays in, takes out and refusesAdvanced · 10 min
- Up and Down the StairsClimb a staircase one step at a time and come back downAdvanced · 10 min
- Shopping List MenuA menu that adds to a list until you leaveAdvanced · 9 min
Write the tests
- Test a Clamp FunctionKeeping a number inside a rangeBeginner · 8 min
- Test a Fizz Pop GameA counting game with multiples of 3 and 7Beginner · 8 min
- Test a Safe AverageThe mean of a list, even when the list is emptyBeginner · 8 min
- Test Grade BandsScores into letter grades, right up to the boundariesBeginner · 8 min
- Test a Discount CalculatorThree price tiers and the edges between themIntermediate · 12 min
- Test a Palindrome CheckWords and phrases that read the same both waysIntermediate · 12 min
- Test a Word CounterCounting the words of a sentence that has punctuationIntermediate · 12 min
- Test a 12-Hour Clock ConverterTurning 24-hour times into AM and PMIntermediate · 12 min
- Test a Password Strength CheckLength, digits and capitals in a password ruleIntermediate · 12 min
- Test a Sorted List MergeTwo sorted lists into one, without losing anythingAdvanced · 15 min
- Test a Cart Total with CouponsCoupon codes, a minimum spend and roundingAdvanced · 15 min
- Test a Date CheckerDay and month text, with fixed month lengthsAdvanced · 15 min
Data questions
- Books Borrowed This WeekCount a week of library loansBeginner · 3 min
- The Wettest Day in JuneThe most rain that fell in one dayBeginner · 3 min
- Average AttendanceHow often are students in school, across every class?Beginner · 4 min
- Scores Above 80How many students beat 80 on the test?Beginner · 4 min
- Top of the QuizThe student with the best quiz scoreBeginner · 4 min
- Canteen Sales on MondayEverything the canteen sold in one dayBeginner · 3 min
- Best Seller of the WeekWhich canteen item sold the most over five days?Intermediate · 7 min
- Pass PercentageWhat share of the class passed the exam?Intermediate · 6 min
- Strong in Math and ScienceStudents who did well in two subjects at onceIntermediate · 6 min
- The Three Fastest RunnersSports day: who were the top three in the 100 meters?Intermediate · 7 min
- Bake Sale TakingsPrices and sales in, money raised outIntermediate · 6 min
- Best House on AverageWhich house earns the most points per student?Intermediate · 8 min
- The Most Borrowed GenreTwo library files, one favorite genreAdvanced · 10 min
- Monthly Rainfall TotalsDated rain readings, one total for each monthAdvanced · 10 min
- Which Club Grew the MostTwo years of club members comparedAdvanced · 10 min
Draw this picture
- Square Turning RightA square that hangs below its starting pointBeginner · 3 min
- Draw a RectangleTwo long sides and two short onesBeginner · 3 min
- Draw a TriangleThree equal sides, three turnsBeginner · 3 min
- Draw a PentagonFive equal sidesBeginner · 4 min
- Draw a Plus SignFour arms from one pointBeginner · 4 min
- Draw a StaircaseFive steps going upBeginner · 4 min
- An Orange SquareA square filled with colorBeginner · 4 min
- A Five-Pointed StarFive lines and five sharp turnsIntermediate · 5 min
- Draw a HouseA square with a triangle roofIntermediate · 6 min
- A Row of Five SquaresFive squares with gaps between themIntermediate · 6 min
- A Striped FlagThree stripes, three colorsIntermediate · 8 min
- A Polygon From a NumberOne number decides the shapeIntermediate · 6 min
- A Square SpiralEach line a little longer than the lastIntermediate · 6 min
- A Small CheckerboardRows and columns of squares, every other one filledAdvanced · 12 min
- Squares Inside SquaresFive squares around one centerAdvanced · 10 min