HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_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 →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

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

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Quizzes
  2. /The file words.txt holds three lines, red, green and blue, each with a new line at its end. A program reads part of it with read, then loops over the rest. What does the program print?
Python ProgrammingAdvancedHigh School (11–12)Python Going Further › Files and Data FormatsClass 12 BoardPCAP (Python Institute)
+1 more exams
A-Level
A-LevelPCAP (Python Institute)
StemPy LabCreated by StemPy Lab

The file words.txt holds three lines, red, green and blue, each with a new line at its end. A program reads part of it with read, then loops over the rest. with open("words.txt") as f: start = f.read(5) for line in f: print(line.strip().upper(), end=" ") print(repr(start)) What does the program print?

Log in to save
← All Quizzes
← A program writes to a new file with write and with print, then reads the whole file back. It prints nothing on the screen. Which of these give True after the code? Choose every correct option.A program starts with two import lines. Each option below is then run as the next line of the program, on its own. Which lines run with no error? Choose every correct option. →
More onPython Going Further › Files and Data Formats

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. A program writes three lines to a file, then adds up the lines that are numbers. A line that is…Hard
  2. A program writes to a new file with write and with print, then reads the whole file back. It…Hard
  3. A program writes three bytes to a binary file, then reads them into a bytearray. What does the…Hard
  4. A class adds lines to a text file, and reads the file back. The folder has no file log.txt at the…Hard
  5. A program writes to a file inside a with block, then uses the file object after the block. What…Medium
All questions on this topic →

Problems on this topic

  1. A to-do list is kept in a JSON file as a list of texts…Medium
  2. Write load_list(name) that gives the list that is saved in a JSON file…Medium
  3. For data = {"p": (1, 2), 3: "x", "t": {"a"}}, say what json.dumps(data) does, and what you must…Medium
  4. Write a CSV file scores.csv with the header name,score and the rows Asha,72 and Rao, Ravi,85 (the…Easy
All problems on this topic →