Skip to content

Course home

Sign up

Input/output

EasyMediumHard
123
Question 3

A program is required to process data about stellar observations. The data is stored in a comma-separated value text file named Stars.txt.

The columns in the data file are:

  • constellation
  • star_name
  • magnitude

Open file Q06.py and write a program to meet these requirements:

  • Create a unique catalog ID for each star. A valid catalog ID is a single string consisting of (in this order):
    • The last three letters of the constellation name, converted to UPPERCASE
    • The integer part of the magnitude multiplied by 10 (e.g. if magnitude is 1.97, its integer part is 1, yielding 10)
    • The first two letters of the star_name, converted to lowercase
  • Create a record for each star. A valid record consists of (in this order):
    • The generated catalog ID, the constellation (as a string), the star_name (as a string), and the magnitude (as a float/decimal)
  • Store the record for each star in a 2D list named starCatalog
  • Call the supplied subprogram, renderCatalog(), to show the contents of starCatalog
  • The program must work with any number of lines in the data file.

Use comments, white space, and indentation to make your program easy to read and understand.

Do not add any additional functionality.

Save your amended code as Q06FINISHED.py

[15]
Markscheme

Input/output Questions

  1. GCSE
  2. /Computer Science
  3. /Input/output

25 exam-style questions on Edexcel GCSE Computer Science Input/output, covering Accepting and responding to user input, Reading and writing CSV text files, Implementing validation, and Implementing authentication. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank