C1M1_Assignment - Programming Assignment: Working with a Virtual Library

I completed the assignment according to the guidelines:

I received the following message after submiting the assignment as follows:

There was a problem compiling the code from your notebook, please check that you saved before submitting. Details:
unterminated triple-quoted string literal (detected at line 75) (, line 73)

The import test_your_code does not seem to be importing.

Under Exercise 1: Book Information:

The test your code code did not compile.

Error: NameError Traceback (most recent call last)
Cell In [2], line 2
1 # Test your code!
----> 2 test_your_code.exercise_1a(book_title, author, year_published, available_copies)

NameError: name ‘book_title’ is not defined

Under Exercise 1-B: Print Statements:

The information did not compile

Error: NameError Traceback (most recent call last)
Cell In [4], line 4
1 ### START CODE HERE ###
2
3 # Print the Title: book_title using an f-string
----> 4 print(f"Title: {book_title}“)
6 # Print the Author: author using an f-string
7 print(f"Author: {author}”)

NameError: name ‘book_title’ is not defined

Under Exercise 2: Checking Out a Book

The information did not compile:

Error: ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In [3], line 2
1 # Test your code!
----> 2 test_your_code.exercise_2(available_copies)

NameError: name ‘available_copies’ is not defined

Under ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In [3], line 2
1 # Test your code!
----> 2 test_your_code.exercise_2(available_copies)

NameError: name ‘available_copies’ is not defined
The information did not compile

Error: ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In [4], line 2
1 # Test your code!
----> 2 test_your_code.exercise_3(requested_book)

NameError: name ‘requested_book’ is not defined

I entered the help section, and chose Get Latest Version.

I used the coach to test my code.

Hi @CoachDg,

These are some of the common mistakes I have seen learners make with the assignments of this course when they get these errors like these. See if you are doing the following:

  1. Not executing the cells - Learners often “write” code in the exercise cell which is correct, but they don’t execute/run that cell and instead execute the test cell directly.

Think of programming in this way: A computer/Jupyter notebook cannot see or read. It only does what you will ask it to do. When you write code and not execute that cell, the computer/notebook does not know what is written in it (this is often why errors like NameError: name ‘requested_book’ is not defined appear). Only when you execute the cells, all the variables are initialised for the computer/notebook to know what’s in it, what is it that you want it to do. So the solution to this is that you have to run/execute the exercise cells before you run/execute the test cells.

  1. Not executing all of the notebook cells - Learners often start working on the assignment and then take a break. After the break they re-open the assignment and resume their work from where they left it. This approach is also incorrect because of reasons described in (1), because all of the executions you made previously are forgotten by the computer/notebook, even when the outputs of the cells is being displayed in the notebook.

Let’s say, you had worked your way up to exercise 2 when you decided to take a break. After the break you come back and start executing/running the cells of exercise 3 directly. You will see errors because the computer/notebook doesn’t remember what had happened before. So the solution to this is, every time you resume your work, you have to run all of the notebook cells from top to bottom before continuing with your work. So in the example I gave you, you have to run all of the cells before exercise 3 in order to continuing working from exercise 3 onwards.

I hope what I explained made sense. Try these solutions, and if your issues remain, let me know.

Best,
Mubsi

1 Like

Thank you. This worked.

1 Like