HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClassesGroups

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Blog

Account

  • Dashboard
  • My Content
  • Profile
  • Log in
© 2026 senLearn. All rights reserved.HelpAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /PCAP (Python Institute)

PCAP (Python Institute) problems

57 problems for PCAP (Python Institute) practice, in Python Programming, each with a worked solution. Try each one on paper first, then check your answer.

Other examsJEE MainNEETBITSATWBJEEBoard ExamOlympiadSATAPA-LevelIBGaokaoPCEP (Python Institute)

Pick a subject to see its topics.

57 problems
Type:
1.
A pipeline has three stages. For the input "Hello, World", it should give ["hello", "world"], but…
High School (11–12), High School (9–10), Undergraduate, General · Testing and DebuggingA-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
2.
A function is_even(n) should say whether a whole number is even.
High School (11–12), High School (9–10), Undergraduate, General · Testing and DebuggingA-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Easy
3.
Write an endless generator primes() that gives 2, 3, 5, 7, 11,...
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Hard
4.
Write an endless generator squares() that gives 1, 4, 9, 16,...
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Medium
5.
Follow the generator
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Medium
6.
Used up
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Medium
7.
For each, say whether it is an iterable that is not an iterator, or an iterator, and whether it can…
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Easy
8.
A list of pairs students = [("Asha", 72), ("Ravi", 85), ("Meera", 72), ("Kabir", 90)].
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Medium
9.
Any or all?
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Easy
10.
Given names = ["Asha", "Ravi", "Meera"] and marks = [72, 85, 64], use zip and a comprehension to…
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Easy
11.
The matrix is m = [[1, 2], [3, 4], [5, 6]], three rows of two.
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Medium
12.
Write this comprehension as a plain loop, and say what it gives for numbers = [1, 2, 3, 4, 5].
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Easy
13.
Write each loop as a list comprehension.
High School (11–12), High School (9–10), Undergraduate, General · Comprehensions, Iterators and GeneratorsPCAP (Python Institute)StemPy LabStemPy Lab
Easy
14.
A to-do list is kept in a JSON file as a list of texts.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsA-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
15.
Write load_list(name) that gives the list that is saved in a JSON file.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsA-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
16.
A file marks.txt holds Asha:72, Ravi:85, Meera:64, one on each line.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsBoard Exam, A-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
17.
Write a function longest_line(name) that gives the longest line of a file, without its new line.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsBoard Exam, A-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Easy
18.
Make a file poem.txt with the three lines roses are red, violets are blue and sugar is sweet.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsBoard Exam, A-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
19.
A file nums.txt has one number on each line: 4, 9, 2, 7.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsBoard Exam, A-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Easy
20.
Write a function read_number(name) that reads a file with one whole number in it, and gives the…
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsBoard Exam, A-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
21.
A file visits.txt is made with "w", and the line Asha is written.
High School (11–12), High School (9–10), Undergraduate, General · Files and Data FormatsBoard Exam, A-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Easy
22.
A class Note has an attribute rupees. Write __lt__ and __str__ so that sorted puts a list of notes…
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsPCAP (Python Institute)StemPy LabStemPy Lab
Medium
23.
For each line of code, name the special method that Python calls.
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsPCAP (Python Institute)StemPy LabStemPy Lab
Easy
24.
The loop below works for any animal. Add a class Bird that says Tweet, and a class Parrot built on…
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsA-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Medium
25.
Who says what?
High School (11–12), High School (9–10), Undergraduate, General · Inheritance and Special Methods, Classes and ObjectsA-Level, IB, PCAP (Python Institute)StemPy LabStemPy Lab
Easy
Page 1 of 3

Showing 1–25 of 57