MCQs on Working with Data | MATLAB

Importing Data from Text Files and Excel

  1. Which Python library is commonly used to import data from CSV files?
    • A) matplotlib
    • B) numpy
    • C) pandas
    • D) seaborn
  2. Which function is used to read data from an Excel file using pandas?
    • A) read_csv()
    • B) read_excel()
    • C) read_table()
    • D) load_excel()
  3. To read a CSV file from a URL using pandas, which function is used?
    • A) read_file()
    • B) read_csv()
    • C) read_url()
    • D) import_csv()
  4. In pandas, what does the sep parameter in the read_csv() function specify?
    • A) The file format
    • B) The delimiter used in the file
    • C) The column headers
    • D) The index column
  5. When reading an Excel file with multiple sheets, which argument should be used to specify the sheet name?
    • A) sheet_name
    • B) sheet
    • C) name
    • D) sheet_index
  6. Which of the following is the default delimiter for the read_csv() function in pandas?
    • A) Comma (,)
    • B) Tab (\t)
    • C) Semicolon (;)
    • D) Space ()
  7. What function in pandas would you use to check the first few rows of a dataset after importing it?
    • A) head()
    • B) tail()
    • C) info()
    • D) describe()
  8. If a CSV file has no header row, which parameter in read_csv() should be set to None?
    • A) header=None
    • B) columns=None
    • C) rows=None
    • D) index=None
  9. How would you import data from a tab-delimited text file into pandas?
    • A) read_tab()
    • B) read_csv(sep='\t')
    • C) read_table()
    • D) read_text()
  10. When importing data from a CSV file with no specific column names, what can be used in pandas to create column names?
    • A) columns=['col1', 'col2', 'col3']
    • B) headers=['col1', 'col2', 'col3']
    • C) col_names=['col1', 'col2', 'col3']
    • D) columns_names=['col1', 'col2', 'col3']

Basic File I/O Operations

  1. Which Python function is used to open a file for reading?
  • A) open_file()
  • B) open()
  • C) read_file()
  • D) file_open()
  1. What is the default mode for opening a file using the open() function in Python?
  • A) Write mode
  • B) Read mode
  • C) Append mode
  • D) Binary mode
  1. To write data to a text file and overwrite the existing content, which mode should be used with open()?
  • A) w
  • B) a
  • C) r
  • D) wb
  1. Which method is used to read all lines from an open file into a list?
  • A) read()
  • B) readlines()
  • C) readfile()
  • D) read_all()
  1. Which function in Python is used to save data to a CSV file?
  • A) write_csv()
  • B) save_csv()
  • C) to_csv()
  • D) export_csv()
  1. To append data to an existing file, which mode should be used with the open() function?
  • A) w
  • B) r
  • C) a
  • D) rw
  1. What is the purpose of the with statement when opening a file in Python?
  • A) To automatically close the file after reading
  • B) To open the file in read mode
  • C) To prevent file access errors
  • D) To allow multiple files to be opened at once
  1. In Python, what function is used to check if a file exists before opening it?
  • A) file_exists()
  • B) exists()
  • C) os.path.exists()
  • D) isfile()
  1. What does the flush() method do when working with files in Python?
  • A) Writes data to the file
  • B) Clears the file contents
  • C) Forces any unwritten data to be written to the file
  • D) Deletes the file data
  1. Which of the following is the correct way to close an open file in Python?
  • A) close()
  • B) file.close()
  • C) end()
  • D) finish()

Simple Data Visualization

  1. Which library is commonly used for simple data visualization in Python?
  • A) pandas
  • B) numpy
  • C) matplotlib
  • D) scipy
  1. Which function in Matplotlib is used to create a simple line plot?
  • A) plot()
  • B) scatter()
  • C) bar()
  • D) line()
  1. What is the default plot style in Matplotlib for a line plot?
  • A) Dotted line
  • B) Solid line
  • C) Dashed line
  • D) No line
  1. How can you add a title to a plot in Matplotlib?
  • A) title()
  • B) set_title()
  • C) add_title()
  • D) set_label()
  1. In Matplotlib, which parameter controls the line color in a plot?
  • A) color
  • B) linecolor
  • C) shade
  • D) col
  1. Which function is used to create a bar plot in Matplotlib?
  • A) bar()
  • B) plot()
  • C) scatter()
  • D) hist()
  1. In a scatter plot, how can you adjust the size of the markers?
  • A) size
  • B) marker_size
  • C) s
  • D) fontsize
  1. What function is used to show the plot in Matplotlib after creating it?
  • A) display()
  • B) show()
  • C) render()
  • D) view()
  1. To customize the grid lines in Matplotlib, which function is used?
  • A) grid()
  • B) show_grid()
  • C) set_grid()
  • D) add_grid()
  1. Which Matplotlib function is used to create a histogram?
  • A) scatter()
  • B) bar()
  • C) plot()
  • D) hist()

Answers

QnoAnswer (Option with Text)
1C) pandas
2B) read_excel()
3B) read_csv()
4B) The delimiter used in the file
5A) sheet_name
6A) Comma (,)
7A) head()
8A) header=None
9B) read_csv(sep='\t')
10A) columns=['col1', 'col2', 'col3']
11B) open()
12B) Read mode
13A) w
14B) readlines()
15C) to_csv()
16C) a
17A) To automatically close the file after reading
18C) os.path.exists()
19C) Forces any unwritten data to be written to the file
20A) close()
21C) matplotlib
22A) plot()
23B) Solid line
24B) set_title()
25A) color
26A) bar()
27C) s
28B) show()
29A) grid()
30D) hist()

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top