<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;Input and Output1.1&nbsp;&nbsp;Keyboard input1.2&nbsp;&nbsp;Screen output1.2.1&nbsp;&nbsp;Formatting output with str.format()1.2.2&nbsp;&nbsp;Printing arrays1.3&nbsp;&nbsp;File input1.3.1&nbsp;&nbsp;Reading data from a text file1.3.2&nbsp;&nbsp;Reading data from a CSV file1.4&nbsp;&nbsp;File output1.4.1&nbsp;&nbsp;Writing data to a text file1.4.2&nbsp;&nbsp;Writing data to a CSV file1.5&nbsp;&nbsp;Exercises<jupyter_code>import numpy as np<jupyter_output><empty_output><jupyter_text>Input and Output================A good relationship depends on good communication. In this chapter youlearn how to communicate with Python. Of course, communicating is atwo-way street: input and output. Generally, when you have Pythonperform some task, you need to feed it information---input. When it isdone with that task, it reports back to you the results of itscalculations---output.There are two venues for input that concern us: the computer keyboardand the input data file. Similarly, there are two venues for output: thecomputer screen and the output data file. We start with input from thekeyboard and output to the computer screen. Then we deal with data fileinput and output---or "io." Keyboard input--------------Many computer programs need input from the user. In `chap2:ScriptExmp1`,the program needed the distance traveled as an input in order todetermine the duration of the trip and the cost of the gasoline. As youmight like to use this same script to determine the cost of severaldifferent trips, it would be useful if the program requested that inputwhen it was run from the IPython shell.Python has a function called `raw_input` (renamed `input` in Python 3)for getting input from the user and assigning it a variable name. It hasthe form<jupyter_code>strname = input("prompt to user ")<jupyter_output>prompt to user<jupyter_text>When the `input` statement is executed, it prints the text in thequotes to the computer screen and waits for input from the user. Theuser types a string of characters and presses the return key. The`input` function then assigns that string to the variable name onthe right of the assignment operator `=`.Let's try it out this snippet of code in the IPython shell.<jupyter_code>distance = input("Input distance of trip in miles: ")<jupyter_output>Input distance of trip in miles: 450<jupyter_text>Python prints out the string argument of the `input` function andwaits for a response from you. Let's go ahead and type `450` for "450miles" and press return. Now type the variable name `distance` to seeits value<jupyter_code>distance<jupyter_output><empty_output><jupyter_text>The value of the `distance` is `450` as expected, but it is a string(the `u` stands for "unicode" which refers to the string coding systemPython uses). Because we want to use `450` as a number and not adistance, we need to convert it from a string to a number. We can dothat with the `eval` function by writing<jupyter_code>distance = eval(distance)
distance<jupyter_output><empty_output><jupyter_text>The `eval` function has converted `distance` to an integer. This is fineand we are ready to move on. However, we might prefer that `distance` bea float instead of an integer. There are two ways to do this. We couldassume the user is very smart and will type "`450.`" instead of "`450`",which will cause distance to be a float when `eval` does the conversion.That is, the number 450 is dynamically typed to be a float or an integerdepending on whether or not the user uses a decimal point.Alternatively, we could use the function `float` in place of `eval`,which would ensure that `distance` is a floating point variable. Thus,our code would look like this (including the user response):<jupyter_code>distance = input("Input distance of trip in miles: ")
distance
distance = float(distance)
distance<jupyter_output><empty_output><jupyter_text>Now let's incorporate what we have learned into the code we wrote for`chap2:ScriptExmp1`<jupyter_code># Calculates time, gallons of gas used, and cost of gasoline for a trip

distance = input("Input distance of trip in miles: ")
distance = float(distance)

mpg = 30.               # car mileage
speed = 60.             # average speed
costPerGallon = 4.10    # price of gas

time = distance/speed
gallons = distance/mpg
cost = gallons*costPerGallon<jupyter_output>Input distance of trip in miles: 450<jupyter_text>Lines 4 and 5 can be combined into a single line, which is a little moreefficient:<jupyter_code>distance = float(input("Input distance of trip in miles: "))<jupyter_output>Input distance of trip in miles: 450<jupyter_text>Whether you use `float` or `int` or `eval` depends on whether you want afloat, an integer, or a dynamically typed variable. In this program, itdoesn't matter.Now you can simply run the program and then type `time`, `gallons`, and`cost` to view the results of the calculations done by the program.Before moving on to output, we note that sometimes you may want stringinput rather that numerical input. For example, you might want the userto input their name, in which case you would simply use the `input`function without converting its output. Screen output-------------It would be much more convenient if the program in the previous sectionwould simply write its output to the computer screen, instead ofrequiring the user to type `time`, `gallons`, and `cost` to view theresults. Fortunately, this can be accomplished very simply usingPython's `print` function. For example, simply including the statement`print(time, gallons, cost)` after line 12, running the program wouldgive the following result: ``` ipythonIn [1]: run myTripIO.pyWhat is the distance of your trip in miles? 450(7.5, 15.0, 61.49999999999999)``` The program prints out the results as a tuple of time (in hours),gasoline used (in gallons), and cost (in dollars). Of course, theprogram doesn't give the user a clue as to which quantity is which. Theuser has to know. Formatting output with `str.format()`We can clean up the output of the example above and make it considerablymore user friendly. The program below demonstrates how to do this.<jupyter_code># Calculates time, gallons of gas used, and cost of gasoline for
# a trip

distance = float(input("Input distance of trip in miles: "))
mpg = 30.               # car mileage
speed = 60.             # average speed
costPerGallon = 4.10    # price of gas

time = distance/speed
gallons = distance/mpg
cost = gallons*costPerGallon

print("\nDuration of trip = {0:0.1f} hours".format(time))
print("Gasoline used = {0:0.1f} gallons (@ {1:0.0f} mpg)"
      .format(gallons, mpg))
print("Cost of gasoline = ${0:0.2f} (@ ${1:0.2f}/gallon)"
      .format(cost, costPerGallon))<jupyter_output>Input distance of trip in miles: 450

Duration of trip = 7.5 hours
Gasoline used = 15.0 gallons (@ 30 mpg)
Cost of gasoline = $61.50 (@ $4.10/gallon)<jupyter_text>The final two `print` function calls in this script are continued on asecond line in order to improve readability. Running this program, withthe distance provided by the user, gives<jupyter_code>run myTripNiceIO.py<jupyter_output>What is the trip distance in miles? 450

Duration of trip = 7.5 hours
Gasoline used = 15.0 gallons (@ 30 mpg)
Cost of gasoline = $61.50 (@ $4.10/gallon)<jupyter_text>Now the output is presented in a way that is immediately understandableto the user. Moreover, the numerical output is formatted with anappropriate number of digits to the right of the decimal point. For goodmeasure, we also included the assumed mileage (30 mpg) and the cost ofthe gasoline. All of this is controlled by the `str.format()` functionwithin the `print` function.The argument of the `print` function is of the form `str.format()` where`str` is a string that contains text that is written to be the screen,as well as certain format specifiers contained in curly braces `{}`. The`format` function contains the list of variables that are to be printed.- The `\n` at the start of the string in the `print` statement on line 12 in the newline character. It creates the blank line before the output is printed.- The positions of the curly braces determine where the variables in the `format` function at the end of the statement are printed.- The format string inside the curly braces specifies how each variable in the `format` function is printed.- The number before the colon in the format string specifies which variable in the list in the `format` function is printed. Remember, Python is zero-indexed, so 0 means the first variable is printed, 1 means the second variable, *etc*.-  The zero after the colon specifies the *minimum* number of spaces reserved for printing out the variable in the format function. A zero means that only as many spaces as needed will be used.- The number after the period specifies the number of digits to the right of the decimal point that will be printed: `1` for `time` and `gallons` and `2` for `cost`.- The `f` specifies that a number with a fixed number of decimal points. If the `f` format specifier is replaced with `e`, then the number is printed out in exponential format (scientific notation).In addition to `f` and `e` format types, there are two more that arecommonly used: `d` for integers (digits) and `s` for strings. There are,in fact, many more formatting possibilities. Python has a whole "FormatSpecification Mini-Language" that is documented at. It's veryflexible but arcane. You might find it simplest to look at the "Formatexamples" section further down the same web page.The program below illustrates most of the formatting you will need forwriting a few variables, be they strings, integers, or floats, to screenor to data files (which we discuss in the next section).<jupyter_code>string1 = "How"
string2 = "<NAME>?"
int1 = 34
int2 = 942885
float1 = -3.0
float2 = 3.141592653589793e-14

print(' ***')
print(string1)
print(string1 + ' ' + string2)
print(' 1. {} {}'.format(string1, string2))
print(' 2. {0:s} {1:s}'.format(string1, string2))
print(' 3. {0:s} {0:s} {1:s} - {0:s} {1:s}'
      .format(string1, string2))
print(' 4. {0:10s}{1:5s}'
      .format(string1, string2))
print(' ***')
print(int1, int2)
print(' 6. {0:d} {1:d}'.format(int1, int2))
print(' 7. {0:8d} {1:10d}'.format(int1, int2))
print(' ***')
print(' 8. {0:0.3f}'.format(float1))
print(' 9. {0:6.3f}'.format(float1))
print('10. {0:8.3f}'.format(float1))
print(2*'11. {0:8.3f}'.format(float1))
print(' ***')
print('12. {0:0.3e}'.format(float2))
print('13. {0:10.3e}'.format(float2))
print('14. {0:10.3f}'.format(float2))
print(' ***')
print('15. 12345678901234567890')
print('16. {0:s}--{1:8d},{2:10.3e}'
      .format(string2, int1, float2))<jupyter_output>***
How
How are you my friend?
 1. How are you my friend?
 2. How are you my friend?
 3. How How are you my friend? - How are you my friend?
 4. How       are you my friend?
 ***
34 942885
 6. 34 942885
 7.       34     942885
 ***
 8. -3.000
 9. -3.000
10.   -3.000
11.   -3.00011.   -3.000
 ***
12. 3.142e-14
13.  3.142e-14
14.      0.000
 ***
15. 12345678901234567890
16. are you my friend?--      34, 3.142e-14<jupyter_text>Successive empty brackets `{}` like those that appear in the statementabove `print(' 1. {} {}'.format(string1, string2))` are numberedconsecutively starting at 0 and will print out whatever variables appearinside the `format()` method using their default format.Finally, note that the code starting on lines 14 and 16 each are splitinto two lines. We have done this so that the lines fit on the pagewithout running off the edge. Python allows you to break lines up likethis to improve readability.  Printing arraysFormatting NumPy arrays for printing requires another approach. As anexample, let's create an array and then format it in various ways. Fromthe IPython terminal<jupyter_code>a = np.linspace(3, 19, 7)
print(a)<jupyter_output>[ 3.          5.66666667  8.33333333 11.         13.66666667 16.33333333
 19.        ]<jupyter_text>Simply using the `print` function does print out the array, but perhapsnot in the format you desire. To control the output format, you use theNumPy function `set_printoptions`. For example, suppose you want to seeno more than two digits to the right of the decimal point. Then yousimply write<jupyter_code>np.set_printoptions(precision=2)
print(a)<jupyter_output>[ 3.    5.67  8.33 11.   13.67 16.33 19.  ]<jupyter_text>If you want to change the number of digits to the right of the decimalpoint to 4, you set the keyword argument `precision` to 4<jupyter_code>np.set_printoptions(precision=4)
print(a)<jupyter_output>[ 3.      5.6667  8.3333 11.     13.6667 16.3333 19.    ]<jupyter_text>Suppose you want to use scientific notation. The method for doing it issomewhat arcane, using something called a `lambda` function. For now,you don't need to understand how it works to use it. Just follow theexamples shown below, which illustrate several different output formatsusing the `print` function with NumPy arrays.<jupyter_code>np.set_printoptions(formatter={'float': lambda x: format(x, '6.2e')})
print(a)<jupyter_output>[3.00e+00 5.67e+00 8.33e+00 1.10e+01 1.37e+01 1.63e+01 1.90e+01]<jupyter_text>To specify the format of the output, you use the `formatter` keywordargument. The first entry to the right of the curly bracket is a stringthat can be `'float'`, as it is above, or `'int'`, or `'str'`, or anumber of other data types that you can look up in the online NumPydocumentation. The only other thing you should change is the formatspecifier string. In the above example, it is `'6.2e'`, specifying thatPython should allocate at least 6 spaces, with 2 digits to the right ofthe decimal point in scientific (exponential) notation. For fixed widthfloats with 3 digits to the right of the decimal point, use the `f` inplace of the `e` format specifier, as follows<jupyter_code>np.set_printoptions(formatter={'float': lambda x: format(x, '6.3f')})
print(a)<jupyter_output>[ 3.000  5.667  8.333 11.000 13.667 16.333 19.000]<jupyter_text>To return to the default format, type the following<jupyter_code>np.set_printoptions(precision=8)
print(a)<jupyter_output>[ 3.          5.66666667  8.33333333 11.         13.66666667 16.33333333
 19.        ]<jupyter_text>The `set_printoptions` is a NumPy function, so if you use it in a scriptor program, you should call it by writing `np.set_printoptions`. File input---------- Reading data from a text fileOften you would like to analyze data that you have stored in a textfile. Consider, for example, the data file below for an experimentmeasuring the free fall of a mass. ```Data for falling mass experimentDate: 16-Aug-2013Data taken by <NAME> Johndata point      time (sec)      height (mm)     uncertainty (mm)    0               0.0             180             3.5    1               0.5             182             4.5    2               1.0             178             4.0    3               1.5             165             5.5    4               2.0             160             2.5    5               2.5             148             3.0    6               3.0             136             2.5    7               3.5             120             3.0    8               4.0              99             4.0    9               4.5              83             2.5   10               5.0              55             3.6   11               5.5              35             1.75   12               6.0               5             0.75``` We would like to read these data into a Python program, associating thedata in each column with an appropriately named array. While there are amultitude of ways to do this in Python, the simplest by far is to usethe NumPy `loadtxt` function, whose use we illustrate here. Suppose thatthe name of the text file is `MyData.txt`. Then we can read the datainto four different arrays with the following statement<jupyter_code>dataPt, time, height, error = np.loadtxt("MyData.txt", skiprows=5 , unpack=True)<jupyter_output><empty_output><jupyter_text>In this case, the `loadtxt` function takes three arguments: the first isa string that is the name of the file to be read, the second tells`loadtxt` to skip the first 5 lines at the top of file, sometimes calledthe *header*, and the third tells `loadtxt` to output the data (*unpack*the data) so that it can be directly read into arrays. `loadtxt` readshowever many columns of data are present in the text file to the arraynames listed to the left of the "`=`" sign. The names labeling thecolumns in the text file are not used, but you are free to choose thesame or similar names, of course, as long as they are legal array names.By the way, for the above `loadtxt` call to work, the file `MyData.txt`should be in the current working directory of the IPython shell.Otherwise, you need to specify the directory path with the file name.It is critically important that the data file be a *text* file. Itcannot be a MSWord file, for example, or an Excel file, or anythingother than a plain text file. Such files can be created by a text editorprograms like `Notepad` and `Notepad++` (for a PC) or `TextEdit` and`TextWrangler` (for a Mac). They can also be created by MSWord and Excelprovided you explicitly save the files as text files. **Beware**: Youshould exit any text file you make and save it with a program thatallows you to save the text file using **UNIX**-type formatting, whichuses a *line feed* (LF) to end a line. Some programs, like MSWord underWindows, may include a carriage return (CR) character, which can confuse`loadtxt`. Note that we give the file name a `.txt` *extension*, whichindicates to most operating systems that this is a *text* file, asopposed to an Excel file, for example, which might have a `.xlsx` or`.xls` extension.If you don't want to read in all the columns of data, you can specifywhich columns to read in using the `usecols` key word. For example, thecall<jupyter_code>time, height = np.loadtxt('MyData.txt', skiprows=5, usecols = (1,2), unpack=True)<jupyter_output><empty_output><jupyter_text>reads in only columns 1 and 2; columns 0 and 3 are skipped. As aconsequence, only two array names are included to the left of the "`=`"sign, corresponding to the two column that are read. Writing`usecols = (0,2,3)` would skip column 1 and read in only the data incolums 0, 2, and 3. In this case, 3 array names would need to beprovided on the left hand side of the "`=`" sign.One convenient feature of the `loadtxt` function is that it recognizesany *white space* as a column separator: spaces, tabs, *etc.*Finally you should remember that `loadtxt` is a NumPy function. So ifyou are using it in a Python module, you must be sure to include an"`import numpy as np`" statement before calling "`np.loadtxt`".  Reading data from a CSV fileSometimes you have data stored in a spreadsheet program like Excel thatyou would like to read into a Python program. The `fig-ExcelWindow`shown here contains the same data set we saw above in a text file.Excel data sheetWhile there are a number of different approaches one can use to readingsuch files, one of the simplest of most robust is to save thespreadsheet as a CSV ("comma separated value") file, a format which allcommon spreadsheet programs can create and read. So, if your Excelspreadsheet was called `MyData.xlsx`, the CSV file saved using Excel's`Save As` command would by default be `MyData.csv`. It would look likethis ```Data for falling mass experiment,,,Date: 16-Aug-2013,,,Data taken by <NAME> John,,,,,,data point,time (sec),height (mm),uncertainty (mm)0,0,180,3.51,0.5,182,4.52,1,178,43,1.5,165,5.54,2,160,2.55,2.5,148,36,3,136,2.57,3.5,120,38,4,99,49,4.5,83,2.510,5,55,3.611,5.5,35,1.7512,6,5,0.75``` As its name suggests, the CSV file is simply a text file with the datathat was formerly in spreadsheet columns now separated by commas. We canread the data in this file into a Python program using the `loadtxt`NumPy function once again. Here is the code<jupyter_code>dataPt, time, height, error = np.loadtxt("MyData.csv", skiprows=5 , unpack=True, delimiter=',')<jupyter_output><empty_output><jupyter_text>The form of the function is exactly the same as before except we haveadded the argument `delimiter=','` that tells `loadtxt` that the columnsare separated by commas instead of white space (spaces or tabs), whichis the default. Once again, we set the `skiprows` argument to skip theheader at the beginning of the file and to start reading at the firstrow of data. The data are output to the arrays to the right of theassignment operator `=` exactly as in the previous example. File output----------- Writing data to a text fileThere is a plethora of ways to write data to a data file in Python. Wewill stick to one very simple one that's suitable for writing data filesin text format. It uses the NumPy `savetxt` routine, which is thecounterpart of the `loadtxt` routine introduced in the previous section.The general form of the routine is ```np.savetxt(filename, array, fmt="%0.18e", delimiter=" ", newline="\n", header="", footer="", comments=" ")``` We illustrate `savetext` below with a script that first creates fourarrays by reading in the data file `MyData.txt`, as discussed in theprevious section, and then writes that same data set to another file`MyDataOut.txt`.<jupyter_code>import numpy as np

dataPt, time, height, error = np.loadtxt("MyData.txt", skiprows=5, unpack=True)
np.savetxt('MyDataOut.txt', list(zip(dataPt, time, height, error)), fmt="%12.1f")

# Unlike in Python 2, `zip` in Python 3 returns an iterator. For the sake of 
# this exercise, I have exhausted the iterator with `list` -- Loren.<jupyter_output><empty_output><jupyter_text>The first argument of of `savetxt` is a string, the name of the datafile to be created. Here we have chosen the name `MyDataOut.txt`,inserted with quotes, which designates it as a string literal. Beware,if there is already a file of that name on your computer, it will beoverwritten---the old file will be destroyed and a new one will becreated.The second argument is the data array the is to be written to the datafile. Because we want to write not one but four data arrays to the file,we have to package the four data arrays as one, which we do using the`zip` function, a Python function that combines returns a list oftuples, where the $i^\mathrm{th}$ tuple contains the $i^\mathrm{th}$element from each of the arrays (or lists, or tuples) listed as itsarguments. Since there are four arrays, each row will be a tuple withfour entries, producing a table with four columns. Note that the firsttwo arguments, the filename and data array, are regular arguments andthus must appear as the first and second arguments in the correct order.The remaining arguments are all keyword arguments, meaning that they areoptional and can appear in any order, provided you use the keyword.The next argument is a format string that determines how the elements ofthe array are displayed in the data file. The argument is optional and,if left out, is the format `0.18e`, which displays numbers as 18 digitfloats in exponential (scientific) notation. Here we choose a differentformat, `12.1f`, which is a float displayed with 1 digit to the right ofthe decimal point and a minimum width of 12. By choosing 12, which ismore digits than any of the numbers in the various arrays have, weensure that all the columns will have the same width. It also ensuresthat the decimal points in column of numbers are aligned. This isevident in the data file below, <spanclass="title-ref">MyDataOut.txt, which was produced by the abovescript. ```0.0          0.0        180.0          3.51.0          0.5        182.0          4.52.0          1.0        178.0          4.03.0          1.5        165.0          5.54.0          2.0        160.0          2.55.0          2.5        148.0          3.06.0          3.0        136.0          2.57.0          3.5        120.0          3.08.0          4.0         99.0          4.09.0          4.5         83.0          2.5``` We omitted the optional `delimiter` keyword argument, which leaves thedelimiter as the default space.We also omitted the optional `header` keyword argument, which is astring variable that allows you to write header text above the data. Forexample, you might want to label the data columns and also include theinformation that was in the header of the original data file. To do so,you just need to create a string with the information you want toinclude and then use the `header` keyword argument. The code belowillustrates how to do this.<jupyter_code>import numpy as np

dataPt, time, height, error = np.loadtxt("MyData.txt", skiprows=5, unpack=True)

info = 'Data for falling mass experiment'
info += '\nDate: 16-Aug-2013'
info += '\nData taken by <NAME> John'
info += '\n\n   data point    time (sec) height (mm)  '
info += 'uncertainty (mm)'

np.savetxt('MyDataOut.txt', list(zip(dataPt, time, height, error)), header=info, fmt="%12.1f")<jupyter_output><empty_output><jupyter_text>Now the data file produces has a header preceding the data. Notice thatthe header rows all start with a `` comment character, which is thedefault setting for the `savetxt` function. This can be changed usingthe keyword argument `comments`. You can find more information about`savetxt` using the IPython `help` function or from the online NumPydocumentation. ``` Data for falling mass experiment Date: 16-Aug-2013 Data taken by <NAME> John     data point    time (sec) height (mm)  uncertainty (mm)         0.0          0.0        180.0          3.5         1.0          0.5        182.0          4.5         2.0          1.0        178.0          4.0         3.0          1.5        165.0          5.5         4.0          2.0        160.0          2.5         5.0          2.5        148.0          3.0         6.0          3.0        136.0          2.5         7.0          3.5        120.0          3.0         8.0          4.0         99.0          4.0         9.0          4.5         83.0          2.5        10.0          5.0         55.0          3.6        11.0          5.5         35.0          1.8        12.0          6.0          5.0          0.8```  Writing data to a CSV fileTo produce a CSV file, you would specify a comma as the delimiter. Youmight use the `0.1f` format specifier, which leaves no extra spacesbetween the comma data separators, as the file is to be read by aspreadsheet program, which will determine how the numbers are displayed.The code, which could be substituted for the `savetxt` line in the abovecode reads<jupyter_code>np.savetxt('MyDataOut.csv', list(zip(dataPt, time, height, error)), fmt="%0.1f", delimiter=",")<jupyter_output><empty_output><jupyter_text>and produces the following data file ```0.0,0.0,180.0,3.51.0,0.5,182.0,4.52.0,1.0,178.0,4.03.0,1.5,165.0,5.54.0,2.0,160.0,2.55.0,2.5,148.0,3.06.0,3.0,136.0,2.57.0,3.5,120.0,3.08.0,4.0,99.0,4.09.0,4.5,83.0,2.510.0,5.0,55.0,3.611.0,5.5,35.0,1.812.0,6.0,5.0,0.8``` This data file, with a `csv` extension, can be directly read into aspreadsheet program like Excel. Exercises---------1.  Write a Python program that calculates how much money you can spend each day for lunch for the rest of the month based on today's date and how much money you currently have in your lunch account. The program should ask you: (1) how much money you have in your account, (2) what today's date is, and (3) how many days there are in month. The program should return your daily allowance. The results of running your program should look like this: ```How much money (in dollars) in your lunch account? 118.39What day of the month is today? 17How many days in this month? 30You can spend $8.46 each day for the rest of the month.``` *Extra:* Create a dictionary (see `chap3dictionaries`) that stores the number of days in each month (forget about leap years) and have your program ask what month it is rather than the number of days in the month. 2.  From the IPython terminal, create the following three NumPy arrays:<jupyter_code>a = np.array([1, 3, 5, 7])
b = np.array([8, 7, 5, 4])
c = np.array([0, 9,-6,-8])<jupyter_output><empty_output><jupyter_text>Now use the `zip` function to create the object `d` defined as<jupyter_code>d = zip(a, b, c)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08598647165067111, 'fraction_numerical': 0.04614512873180579, 'mean_word_length': 3.62766306129138, 'pattern_counts': {'":': 0, '<': 94, '<?xml version=': 0, '>': 94, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 9, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '25', 'dir': 'jupyter-structured-clean-dedup', 'id': '480631', 'license': 'CC0-1.0', 'n_tokens_mistral': 8830, 'n_tokens_neox': 8009, 'n_words': 3850, 'path': 'Book/chap4/chap4_io.ipynb', 'repo_name': 'lorenghoh/pyman', 'size': '28264'}