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. /A program writes three lines to a file, then adds up the lines that are numbers. A line that is not a number counts as 100. What does the program print?
Python ProgrammingHardHigh 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

A program writes three lines to a file, then adds up the lines that are numbers. A line that is not a number counts as 100. with open("n.txt", "w") as f: f.write("3\nx\n5\n") total = 0 with open("n.txt") as f: for row in f: try: total += int(row) except ValueError: total += 100 print(total, f.closed) What does the program print?

Log in to save
← All Quizzes
← Each option makes a small anonymous function with lambda, and most of them also call it at once. Which options have the value 6, a plain integer? Choose every correct option.A list of words is to be sorted by length, and words of the same length in alphabetical order. The key is missing. Which key, put in place of ____, makes the program print ['fig', 'date', 'kiwi', 'apple']? →
More onPython Going Further › Files and Data Formats

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. The file words.txt holds three lines, red, green and blue, each with a new line at its end. A…Advanced
  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 →