Question 6

You are writing a function named process_data()to read and process numerical input from a file. The function must:
- read the file data.txt,
- attempt to convert the first line into an integer,
- handle file, conversion, or index-related exceptions,
- print the value only if no error occurs,
- and always print a final message after execution.
Which implementation correctly and robustly meets all these conditions? Select the best answer.
  • Question 7

    A dictionary is defined as d = {"a":1, "b":2}. The programmer accesses d["c"]. What happens when this line executes?
  • Question 8

    An online retailer collects customer reviews, order transaction logs, and product ratings.
    Which of the following correctly classifies these types of data? Select the best answer.
  • Question 9

    A program compares two values using == and is. The variables a = 256 and b = 256 are defined.
    What is the expected result of a is b in most Python implementations?
  • Question 10

    The following chart shows how a student spends 24 hours in a day:

    Which statements are most accurate? (Choose two.)