Question about Introduction To NumPy/lesson 4

Hi everyone,

I have a question about line 5 in the 4th lesson of the Introduction to NumPy section (under the Pandas and NumPy Fundamentals course). I understand the code except for what the “r” is in reference to– could someone clarify this? Thank you in advance! :slight_smile:

Screen Shot 2020-07-06 at 6.04.32 PM

Hello @nicole20,

The open() function has two parameters and has its general syntax as open(file, mode) .

The file parameter accepts the path and name of the file
while
The mode parameter defines which mode you want to open the file in and it accepts string values such as :

  • "r" - Read mode, which opens the file for reading
  • "a" - Append mode, Opens the file for appending.
  • "w" - Write mode, Opens the file for writing.
  • "x" - Create mode, Creates the specified file.

I hope this answers your question.

1 Like

Thank you so much! My confusion was with not realizing mode had a default/was optional. (I ended up finding the documentation, which probably should have been my first step. :see_no_evil:)

1 Like