0% found this document useful (0 votes)
22 views

Python - GUI, Numpy and Pandas - Quizizz

Uploaded by

jarvissingh109
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Python - GUI, Numpy and Pandas - Quizizz

Uploaded by

jarvissingh109
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

Worksheets Name

Python - GUI,Numpy and Pandas


Class
Total questions: 30
Worksheet time: 30mins
Date
Instructor name: Anik Acharjee

1. What does the ndim attribute of a NumPy array return?

a) The data type of the array elements. b) The number of dimensions of the array.

c) The size of the array in bytes. d) The total number of elements in the array.

2. What is the shape of an array?

a) The number of elements the array can store. b) The dimensions of the array, represented as a tuple.

c) The memory address where the array is stored. d)


The data type of the array elements.

3. How does the reshape method function in NumPy?

a) b) It changes the total number of elements in the array.


It sorts the array elements.

c) It changes the shape of the array without altering the data. d) It changes the data type of the array elements.

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 1/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

4. What does slicing a NumPy array do?

a) b) It creates a view of the array with selected elements.


It deletes elements from the array.

c) It transposes the array. d)


It creates a new array with a specified shape.

5. What is the result of transposing a 1D NumPy array?

a) The same 1D array. b) A 2D row vector.

c) An error is raised. d) A 2D column vector.

6. Which of the following is the correct way to slice the third column from a 2D NumPy array arr?

a) arr[2] b) arr[2, :]

c) d) arr[..., 2]
arr[:, 2]

7. How can you identify if a reshaped array is a view or a copy?

a) By checking the dtype attribute. b) By checking the size attribute

c) By checking if the base attribute is None. d) By checking the shape attribute.

8. What will be the shape of an array after applying arr.reshape(-1)?

a) The shape will be a 2D array with one row. b) The shape will be a 1D array.

c) The shape will be unchanged. d) The shape will be a 2D array with one column.

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 2/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

9. Which NumPy function is used to transpose a 2D array?

a) b) np.rot90()
np.flip()

c) d) np.swapaxes()
np.transpose()

10. What does the shape attribute of a NumPy array return when applied to a 3x4 array?

a) (4, 3) b) (3, 4)

c) d)
12 3x4

11. Which function is used to create a main window in Tkinter?

a) Tk() b) Frame()

c) mainloop() d)
Window()

12. What is the correct way to start the Tkinter event loop?

a) mainloop() b) startloop()

c) beginloop() d) eventloop()

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 3/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

13. How can you install Tkinter in your system?

a) b) pip install Tkinter


pip install tkinter

c) Tkinter comes pre-installed with Python d)


pip install python-tk

14. How do you change the font color of a label widget in Tkinter?

a) Use the 'fg' option b) Use the 'fontcolor' option

c) Use the 'color' option d) Use the 'textcolor' option

15. What does the following code snippet achieve?


import tkinter as tk
def display_message():
label.config(text="Button clicked!")

root = tk.Tk()
button = tk.Button(root, text="Click me!", command=display_message)
button.pack()
label = tk.Label(root, text="Hello, Tkinter!")
label.pack()
root.mainloop()

a) It creates a label that displays a message when clicked. b) It creates a button with the text "Hello, Tkinter!"

c) It creates a button that changes the label text when clicked. d) It creates a label with the text "Click me!".

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 4/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

16. What does the ‘command’ parameter of the ‘Button()’ widget specify?

a) The color of the button. b) The size of the button.

c) The text displayed on the button. d) The function to execute when the button is clicked.

17. In the context of Tkinter, what does the following code snippet do?
button = tk.Button(root, text="Click me!", command=quit)

a) It creates a button with the text "Click me!" that prints "quit" to b) It creates a button with the text "Click me!" that does nothing
the console when clicked. when clicked.

c) It creates a button with the text "Click me!" that closes the d) It creates a button with the text "Click me!" that opens a new
Tkinter window when clicked. Tkinter window when clicked.

18. What is the missing code in the following snippet to create a Tkinter window with a label displaying "Hello, Tkinter!"?
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="Hello, Tkinter!")
label.______()
root.mainloop()

a) add() b) show()

c) display() d) pack()

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 5/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

19. What is the missing code in the following snippet to create a Tkinter entry widget for user input?
import tkinter as tk
root = tk.Tk()
entry = tk.Entry(root)
entry._____(width=30)
entry.pack()
root.mainloop()

a) config b) EntryWidget

c) create_entry d) entry_create

20. What is the missing code in the following snippet to create a Tkinter button with the text "Clear" that clears the text in the entry widget
when clicked?
def clear_entry():
entry.delete(0, tk.END)
button_clear = tk.Button(root, text="Clear", command=clear_entry)
# Missing code

a) button_clear.pack_forget() b) button_clear.pack()

c) Button.pack() d) button_clear.show()

21. What does the `read_csv()` function in Pandas do?

a) Reads data from a CSV file into a DataFrame. b) Plots data from a CSV file.

c) Counts the number of rows in a CSV file. d) Writes data to a CSV file.

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 6/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

22. What is the default number of rows returned by the `head()` method in Pandas?

a) 5 b) All rows

c) 1 d) 10

23. Which function is used to concatenate two or more DataFrames in Pandas?

a) concat() b) merge()

c) join() d) combine()

24. What does the `to_csv()` function do in Pandas?

a) Converts a CSV file to JSON. b) Writes the DataFrame to a CSV file.

c) Splits a CSV file into smaller chunks. d) Reads data from a CSV file.

25. How do you calculate the sum of a DataFrame or Series in Pandas?

a) total() b) accumulate()

c) sum() d) add()

26. What does the `mean()` function return in Pandas?

a) The mode value. b) The median value

c) The average value. d) The total sum.

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 7/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

27. Which method counts the number of non-NA cells for each column or row?

a) total() b) non_na()

c) number() d) count()

28. What parameter in `read_csv()` is used to specify the delimiter?

a) divide b) split

c) sep d) delim

29. How can you use `head()` to return the first 10 rows of a DataFrame?

a) df.begin(10) b) df.first(10)

c) df.head(10) d) df.top(10)

30. What does the `concat()` function default to when combining DataFrames?

a) Merges on rows. b) Merges on columns.

c) Concatenates along rows. d) Concatenates along columns.

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 8/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

Answer Keys

1. b) The number of dimensions of the array. 2. b) The dimensions of the array, 3. c) It changes the shape of the array without
represented as a tuple. altering the data.

4. b) It creates a view of the array with 5. a) The same 1D array. 6. c)


selected elements. arr[:, 2]

7. c) By checking if the base attribute is None. 8. b) The shape will be a 1D array. 9. c)


np.transpose()

10. b) (3, 4) 11. a) Tk() 12. a) mainloop()

13. c) Tkinter comes pre-installed with Python 14. a) Use the 'fg' option 15. c) It creates a button that changes the
label text when clicked.

16. d) The function to execute when the 17. c) It creates a button with the text 18. d) pack()
button is clicked. "Click me!" that closes the Tkinter
window when clicked.

19. a) config 20. b) button_clear.pack() 21. a) Reads data from a CSV file into a
DataFrame.

22. a) 5 23. a) concat() 24. b) Writes the DataFrame to a CSV file.

25. c) sum() 26. c) The average value. 27. d) count()

28. c) sep 29. c) df.head(10) 30. c) Concatenates along rows.

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 9/10
4/30/24, 10:52 AM Python - GUI,Numpy and Pandas | Quizizz

https://quizizz.com/print/quiz/662f36555a482615f6a76e45 10/10

You might also like