Hello, can someone explain what is the purpose of assigning “False” to “rows_and_columns” parameter?
And later when we actually use the explore_data function, we assign True to rows_and_columns…why?
def explore_data(dataset, start, end, rows_and_columns=False):
dataset_slice = dataset[start:end]
for row in dataset_slice:
print(row)
print('\n') # adds a new (empty) line between rows
if rows_and_columns:
print('Number of rows:', len(dataset))
print('Number of columns:', len(dataset[0]))
print(android_header)
print('\n')
explore_data(android, 0, 3, True)
You could probably just as easily write the function so that rows_and_columns=True is the default. Then if you wanted to use the function to explore the data but not print how many rows and columns it contains, just pass in False for that parameter. My guess is for having us do it this way for the project is to reinforce what we learned about default arguments in functions in an earlier mission. As you grow in your knowledge you’ll be able to write custom functions that have the flexibility and usefulness you need to make analysis easier.