Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
Question 1 of 60 · OpenCV-based image operations · Easy
Which Python library is primarily used for computer vision and image processing tasks?
Not quite. Try another option.
Answer: OpenCV
OpenCV (Open Source Computer Vision Library) is the standard library for image processing and computer vision in Python.
Question 2 of 60 · OpenCV-based image operations · Easy
Which function is used to read an image from a file in OpenCV?
Not quite. Try another option.
Answer: cv2.imread()
cv2.imread() loads an image from the specified file path and returns it as a NumPy array.
Question 3 of 60 · OpenCV-based image operations · Easy
In OpenCV, which color format are images loaded in by default?
Not quite. Try another option.
Answer: BGR
By default, OpenCV reads images in BGR (Blue-Green-Red) order rather than the more common RGB order.
Question 4 of 60 · OpenCV-based image operations · Easy
Which OpenCV function displays an image in a window?
Not quite. Try another option.
Answer: cv2.imshow()
cv2.imshow() opens a window and displays the given image on the screen.
Question 5 of 60 · PyGame-based gaming creation · Easy
PyGame is a Python library mainly used for creating what type of applications?
Not quite. Try another option.
Answer: Games and multimedia
PyGame is a cross-platform library designed for writing video games and multimedia applications in Python.
Question 6 of 60 · PyGame-based gaming creation · Easy
Which function must be called to start using PyGame's modules?
Not quite. Try another option.
Answer: pygame.init()
pygame.init() initializes all imported PyGame modules and must be called before using most features.
Question 7 of 60 · PyGame-based gaming creation · Easy
In PyGame, which object represents the main window or drawing surface?
Not quite. Try another option.
Answer: Surface
A PyGame Surface represents an image or the display window onto which graphics are drawn.
Question 8 of 60 · PyGame-based gaming creation · Easy
Which PyGame concept is typically used to continuously update the game and handle events?
Not quite. Try another option.
Answer: Game loop
A game loop repeatedly processes input, updates the game state, and redraws the screen until the game ends.
Question 9 of 60 · web-scraping-based url access · Easy
Which Python library is commonly used to send HTTP requests to access a URL?
Not quite. Try another option.
Answer: requests
The requests library makes it easy to send HTTP requests and access web content from a URL.
Question 10 of 60 · web-scraping-based url access · Easy
Which library is widely used to parse HTML content during web scraping?
Not quite. Try another option.
Answer: BeautifulSoup
BeautifulSoup parses HTML and XML documents, making it easy to extract data from web pages.
Question 11 of 60 · web-scraping-based url access · Easy
What does the term "web scraping" mean?
Not quite. Try another option.
Answer: Extracting data from websites automatically
Web scraping is the automated process of extracting information from web pages.
Question 12 of 60 · web-scraping-based url access · Easy
An HTTP status code of 200 typically indicates what?
Not quite. Try another option.
Answer: The request succeeded
The status code 200 (OK) means the request was successful and the server returned the requested content.
Question 13 of 60 · data visualization · Easy
Which Python library is one of the most widely used for creating basic plots and charts?
Not quite. Try another option.
Answer: Matplotlib
Matplotlib is a foundational Python library for producing static, animated, and interactive visualizations.
Question 14 of 60 · data visualization · Easy
Which chart type is best suited for showing trends in data over time?
Not quite. Try another option.
Answer: Line chart
Line charts connect data points over a continuous axis, making them ideal for showing trends over time.
Question 15 of 60 · data visualization · Easy
Which library is built on top of Matplotlib and provides attractive statistical graphics?
Not quite. Try another option.
Answer: Seaborn
Seaborn is built on Matplotlib and simplifies creating visually appealing statistical plots.
Question 16 of 60 · data visualization · Easy
Which chart is most appropriate for showing the proportion of parts to a whole?
Not quite. Try another option.
Answer: Pie chart
A pie chart displays each category as a slice, showing how parts contribute to the whole.
Question 17 of 60 · discussion on advanced toolboxes in python · Easy
Which library is commonly used for numerical computing and working with arrays in Python?
Not quite. Try another option.
Answer: NumPy
NumPy provides powerful N-dimensional array objects and tools for numerical computation.
Question 18 of 60 · discussion on advanced toolboxes in python · Easy
Which Python library is primarily used for data analysis and handling tabular data?
Not quite. Try another option.
Answer: Pandas
Pandas provides DataFrame structures that make working with tabular and labeled data easy.
Question 19 of 60 · demonstration of real-world applications · Easy
Which of the following is a real-world application where Python is commonly used?
Not quite. Try another option.
Answer: Data analysis and machine learning
Python is widely applied in real-world domains such as data analysis, machine learning, web development, and automation.
Question 20 of 60 · storytelling · Easy
In the context of data, what does "data storytelling" mainly involve?
Not quite. Try another option.
Answer: Communicating insights using data and visuals
Data storytelling combines data, visuals, and narrative to communicate insights clearly to an audience.
Question 21 of 60 · OpenCV-based image operations · Medium
In OpenCV, when you read an image using cv2.imread(), in what channel order are the pixel values stored by default?
Not quite. Try another option.
Answer: BGR
OpenCV loads color images in BGR order by default, not RGB. This is why you often need cv2.cvtColor(img, cv2.COLOR_BGR2RGB) before displaying with libraries like Matplotlib.
Question 22 of 60 · OpenCV-based image operations · Medium
You want to convert a color image img to grayscale in OpenCV. Which line accomplishes this?
cv2.cvtColor() with the flag cv2.COLOR_BGR2GRAY converts an already-loaded BGR image to grayscale. cv2.imread(img, 0) reads a file path as grayscale but cannot convert an existing array.
Question 23 of 60 · OpenCV-based image operations · Medium
What does the shape attribute img.shape return as (480, 640, 3) indicate about the image?
Not quite. Try another option.
Answer: Height 480, width 640, and 3 color channels
NumPy arrays used by OpenCV store images as (rows, columns, channels), i.e. (height, width, channels). So (480, 640, 3) means height 480, width 640, and 3 (BGR) channels.
Question 24 of 60 · PyGame-based gaming creation · Medium
In a typical PyGame program, which function must be called first to start up all imported PyGame modules?
Not quite. Try another option.
Answer: pygame.init()
pygame.init() initializes all the PyGame submodules and must be called before most other PyGame functionality is used.
Question 25 of 60 · PyGame-based gaming creation · Medium
Inside a PyGame main loop, which call is responsible for actually updating the full screen with everything drawn?
Not quite. Try another option.
Answer: pygame.display.flip()
pygame.display.flip() (or pygame.display.update()) pushes the drawn surface to the visible screen. Without it, drawing operations are not shown to the player.
Question 26 of 60 · PyGame-based gaming creation · Medium
Why is pygame.time.Clock() combined with clock.tick(60) used in a game loop?
Not quite. Try another option.
Answer: To limit the loop to a maximum of 60 frames per second
clock.tick(60) caps the game loop at 60 frames per second, ensuring consistent speed across machines rather than running as fast as the CPU allows.
Question 27 of 60 · PyGame-based gaming creation · Medium
In PyGame, how do you typically detect that the user clicked the window's close button?
Not quite. Try another option.
Answer: Check for event.type == pygame.QUIT in the event loop
The pygame.QUIT event is generated when the user clicks the window close button. Handling it in the event loop lets you exit cleanly.
Question 28 of 60 · web-scraping-based url access · Medium
When scraping a webpage in Python, which combination is most commonly used to fetch the HTML and then parse it?
Not quite. Try another option.
Answer: requests to fetch, BeautifulSoup to parse
The requests library retrieves the raw HTML from a URL, and BeautifulSoup (from bs4) parses that HTML so you can navigate and extract elements.
Question 29 of 60 · web-scraping-based url access · Medium
After response = requests.get(url), which attribute do you check to confirm the request succeeded (HTTP 200)?
Not quite. Try another option.
Answer: response.status_code
response.status_code returns the HTTP status; a value of 200 indicates success. There is also response.ok, but no attribute named success or result.
Question 30 of 60 · web-scraping-based url access · Medium
Using BeautifulSoup, which method returns a list of all <a> anchor tags on a page?
Not quite. Try another option.
Answer: soup.find_all('a')
find_all('a') returns every matching tag as a list, while find('a') and select_one('a') return only the first match.
Question 31 of 60 · web-scraping-based url access · Medium
A website's robots.txt disallows scraping certain paths. What is the correct interpretation for a responsible scraper?
Not quite. Try another option.
Answer: It signals which paths crawlers should not access, and should be respected
robots.txt is a voluntary standard telling automated agents which paths not to crawl. It does not technically block requests, but ethical and often legal practice is to respect it.
Question 32 of 60 · data visualization · Medium
In Matplotlib, which plot type is most appropriate for showing the relationship between two continuous numeric variables?
Not quite. Try another option.
Answer: Scatter plot
A scatter plot maps one variable to the x-axis and another to the y-axis, making it ideal for visualizing correlation or relationships between two continuous variables.
Question 33 of 60 · data visualization · Medium
You want to visualize the distribution and frequency of a single continuous variable such as exam scores. Which chart is best?
Not quite. Try another option.
Answer: Histogram
A histogram groups values into bins and shows how frequently values fall into each range, making it the standard tool for viewing the distribution of one continuous variable.
Question 34 of 60 · data visualization · Medium
In Matplotlib, what is the purpose of calling plt.show() at the end of a plotting script?
Not quite. Try another option.
Answer: It renders and displays the figure window
plt.show() opens a window rendering the current figure. Saving to disk uses plt.savefig(), and clearing uses plt.clf() or plt.close().
Question 35 of 60 · data visualization · Medium
Which library is built on top of Matplotlib and provides high-level functions for attractive statistical graphics?
Not quite. Try another option.
Answer: Seaborn
Seaborn is built on Matplotlib and offers concise, high-level functions (like sns.heatmap and sns.boxplot) for statistical visualizations with attractive default styling.
Question 36 of 60 · discussion on advanced toolboxes in python · Medium
Which Python library is primarily used for numerical computing with efficient multi-dimensional array operations?
Not quite. Try another option.
Answer: NumPy
NumPy provides the ndarray object and vectorized operations that make numerical computation fast and memory-efficient, forming the foundation for many scientific libraries.
Question 37 of 60 · discussion on advanced toolboxes in python · Medium
A data analyst needs to load a CSV file into a labeled, tabular data structure with columns. Which library and object are most appropriate?
Not quite. Try another option.
Answer: pandas DataFrame
The pandas DataFrame is a 2D labeled table ideal for loading, cleaning, and analyzing tabular data, and pd.read_csv() loads a CSV directly into one.
Question 38 of 60 · discussion on advanced toolboxes in python · Medium
Which pair correctly matches a Python toolbox to its main purpose?
Not quite. Try another option.
Answer: scikit-learn → machine learning
scikit-learn is a leading library for classical machine learning tasks such as classification, regression, and clustering. The other pairings mismatch the library and purpose.
Question 39 of 60 · demonstration of real-world applications · Medium
A team builds a Python system that detects faces in a live camera feed. Which library is the natural core of this application?
Not quite. Try another option.
Answer: OpenCV
OpenCV specializes in computer vision tasks like reading video frames and detecting faces (e.g., via Haar cascades or DNN modules), making it the core of such an application.
Question 40 of 60 · demonstration of real-world applications · Medium
A company wants to automatically collect daily product prices from several e-commerce sites into a spreadsheet for analysis. Which workflow best fits?
Not quite. Try another option.
Answer: Scrape pages with requests/BeautifulSoup, then store in a pandas DataFrame
Web scraping libraries collect the price data from each URL, and a pandas DataFrame provides a tabular structure that can easily be exported to a spreadsheet for analysis.
Question 41 of 60 · OpenCV-based image operations · Hard
In OpenCV, you load an image with cv2.imread('img.png') and display it using Matplotlib's plt.imshow(). The colors appear distorted (blues look red). What is the root cause and correct fix?
Not quite. Try another option.
Answer: OpenCV loads images in BGR order while Matplotlib expects RGB; convert using cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
OpenCV stores channels in BGR order, but Matplotlib interprets arrays as RGB. Swapping the channels with cv2.COLOR_BGR2RGB corrects the display.
Question 42 of 60 · OpenCV-based image operations · Hard
You apply a averaging (box) blur kernel to an image, then apply the same kernel again. Compared to a single box blur, the two-pass approach:
Not quite. Try another option.
Answer: Produces a smoothing effect similar to a blur but is not identical to a true box filter
Two convolutions with box kernels are equivalent to convolving with a kernel whose weights are the convolution of the two boxes — a triangular (not uniform) weighting — so it approximates but does not equal a uniform box blur.
Question 43 of 60 · OpenCV-based image operations · Hard
When performing edge detection with cv2.Canny(img, threshold1, threshold2), what best describes the role of the two thresholds in hysteresis?
Not quite. Try another option.
Answer: Pixels above threshold2 are strong edges; pixels between the thresholds become edges only if connected to strong edges
Canny uses hysteresis: gradients above the high threshold are certain edges, and those between low and high are kept only if linked to strong edges, improving continuity while suppressing noise.
Question 44 of 60 · PyGame-based gaming creation · Hard
In a PyGame loop, a developer moves a sprite by adding a fixed number of pixels each frame without using clock.tick(). On faster hardware the object moves too quickly. What is the correct fix?
Not quite. Try another option.
Answer: Multiply movement by delta time (seconds since last frame) so motion is frame-rate independent
Frame-rate independent movement scales displacement by elapsed time (delta time). This ensures consistent speed regardless of how fast frames render.
Question 45 of 60 · PyGame-based gaming creation · Hard
A PyGame program's window becomes unresponsive and shows "Not Responding" during gameplay. Which omission most likely causes this?
Not quite. Try another option.
Answer: The event queue is never processed with pygame.event.get() or pygame.event.pump()
The OS requires the application to pump its event queue. If pygame.event.get()/pump() is never called, the window stops responding to the OS and appears frozen.
Question 46 of 60 · PyGame-based gaming creation · Hard
For pixel-perfect collision between two moving sprites in PyGame, which approach is most accurate but computationally heavier than rectangle collision?
Not quite. Try another option.
Answer: Mask-based collision using pygame.mask.from_surface and mask.overlap
Masks represent the non-transparent pixels of each sprite. mask.overlap detects actual pixel overlap, giving pixel-perfect accuracy at higher computational cost than bounding-box checks.
Question 47 of 60 · web-scraping-based url access · Hard
You scrape a page with requests.get(url) and BeautifulSoup, but the target data is missing from the returned HTML even though it appears in the browser. What is the most probable reason?
Not quite. Try another option.
Answer: The content is rendered client-side by JavaScript after page load, which requests does not execute
requests only fetches the raw HTML; it does not run JavaScript. Data injected by client-side scripts requires a headless browser (e.g., Selenium/Playwright) or the underlying API endpoint.
Question 48 of 60 · web-scraping-based url access · Hard
Which statement about robots.txt and web scraping is most accurate?
Not quite. Try another option.
Answer: It is an advisory standard that requests crawlers avoid certain paths, but it does not technically enforce access control
robots.txt is a voluntary convention read by well-behaved crawlers. It provides no technical enforcement; compliance is ethical/legal, not mechanical.
Question 49 of 60 · web-scraping-based url access · Hard
A scraper repeatedly hits a site and starts receiving HTTP 429 responses. Which combination best addresses this while remaining respectful?
Not quite. Try another option.
Answer: Add delays between requests and implement exponential backoff honoring the Retry-After header
HTTP 429 means "Too Many Requests." The correct response is to slow down, back off exponentially, and respect the server's Retry-After guidance.
Question 50 of 60 · data visualization · Hard
You plot data spanning to on a linear y-axis and small values become invisible near zero. Which change best reveals structure across all magnitudes?
Not quite. Try another option.
Answer: Use a logarithmic y-axis (e.g., plt.yscale('log'))
A log scale compresses several orders of magnitude so both small and large values are visible, revealing multiplicative structure that a linear axis hides.
Question 51 of 60 · data visualization · Hard
When designing a chart for viewers who may be color-blind, which practice is most effective?
Not quite. Try another option.
Answer: Combine a color-blind-safe palette with redundant encodings like markers, line styles, or direct labels
Never rely on color alone. A color-blind-safe palette plus redundant encodings (shapes, patterns, labels) ensures the information is accessible regardless of color perception.
Question 52 of 60 · data visualization · Hard
A bar chart of average sales per region hides the fact that one region has a bimodal distribution. Which visualization better exposes this within-group structure?
Not quite. Try another option.
Answer: A violin plot or box plot showing the distribution shape per region
Bar charts of means discard distributional detail. Violin/box plots reveal spread, skew, and multimodality that a single summary statistic conceals.
Question 53 of 60 · data visualization · Hard
In Matplotlib, what is the key difference between the stateful pyplot interface and the object-oriented (Axes) interface for complex multi-panel figures?
Not quite. Try another option.
Answer: The OO interface gives explicit control over each Axes object, avoiding ambiguity about which subplot commands affect
The stateful pyplot API acts on the "current" axes, which becomes error-prone with many subplots. The OO interface references each Axes explicitly, making complex layouts predictable.
Question 54 of 60 · discussion on advanced toolboxes in python · Hard
You perform an element-wise operation on two large arrays. Why is NumPy vectorization typically much faster than a Python for loop?
Not quite. Try another option.
Answer: NumPy executes the operation in compiled C code over contiguous memory, avoiding per-element Python interpreter overhead
Vectorized NumPy operations run in optimized, compiled C over contiguous typed buffers, eliminating the interpreter overhead incurred by iterating element-by-element in pure Python.
Question 55 of 60 · discussion on advanced toolboxes in python · Hard
A Pandas operation df[df['a'] > 0]['b'] = 5 produces a SettingWithCopyWarning and the change may not persist. What is the correct fix?
Not quite. Try another option.
Answer: Use .loc for combined selection and assignment: df.loc[df['a'] > 0, 'b'] = 5
Chained indexing may operate on a temporary copy. Using a single .loc call for both selection and assignment guarantees the write targets the original DataFrame.
Question 56 of 60 · discussion on advanced toolboxes in python · Hard
When training a scikit-learn model, why should scaling (e.g., StandardScaler) be fit only on the training data and not on the full dataset before splitting?
Not quite. Try another option.
Answer: Fitting on all data leaks test-set statistics into training, producing overly optimistic evaluation
Fitting the scaler on the entire dataset lets test-set information (mean, variance) influence the model, a form of data leakage that inflates performance estimates. Fit on train, then transform both.
Question 57 of 60 · storytelling · Hard
In data storytelling, a stakeholder audience needs to grasp one key takeaway quickly. Which approach best supports this goal?
Not quite. Try another option.
Answer: Lead with a clear headline insight and use annotations to direct attention to the supporting evidence
Effective data storytelling foregrounds the main message and guides the viewer's attention with annotations, rather than dumping raw exploratory output or forcing self-interpretation.
Question 58 of 60 · storytelling · Hard
A chart truncates its y-axis to start at instead of , making a change look dramatic. In the context of ethical storytelling, this is best described as:
Not quite. Try another option.
Answer: A misleading design choice that exaggerates differences and should be disclosed or avoided
Truncating a bar chart's baseline visually exaggerates small differences and can mislead the audience. Ethical storytelling requires honest axis scaling or clear disclosure.
Question 59 of 60 · demonstration of real-world applications · Hard
You must process a live video stream, detect motion, and log events to a dashboard. Which combination of Python tools maps most appropriately to each subtask?
Not quite. Try another option.
Answer: OpenCV for frame capture/motion detection, Pandas for event logging, and Matplotlib/Plotly for the dashboard
Each library fits its role: OpenCV handles video/computer-vision, Pandas structures tabular event logs, and Matplotlib/Plotly visualizes them. The other options mismatch tools to tasks.
Question 60 of 60 · demonstration of real-world applications · Hard
A pipeline scrapes prices hourly, stores them, and predicts trends. To keep it maintainable and avoid re-scraping unchanged pages, which design choice is most sound?
Not quite. Try another option.
Answer: Cache responses with conditional requests (ETag/If-Modified-Since) and separate scraping, storage, and modeling into modular stages
Conditional requests avoid redundant downloads, reducing load and cost, while modular stages improve testability and maintainability. Monolithic functions and full re-scrapes scale poorly.
That's unit 6
Answer a few questions and your score shows up here.
Nearly through. Did unit 6 of ECE181 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 6 of ECE181 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.