Skip to content

Task 6

Created: 2026-04-15

Preamble

Python hosts its official repository of packages at PyPI - Python Package Index. Following are the sequence in which most people discover and use packages:

  1. Discovery: Before installing a package, we must know its name and its suitability for our use. People discover the packages they need from various sources - peers, academic and research publications and newsletters, podcasts, videos.
  2. Fitness for use: The documentation of the package is studied to determine the capacbilities and limitations of the package to decide its fitness for our use.
  3. Preliminary use: A quick tutorial to explore the capabilities of the package followed by in-depth look into how well it meets our expectations.
  4. Inclusion in our program/package: The last step is to incorporate the package into our own programs and packages.

These steps require skills such as studying APIs and documentation, setting up a virtual environment and writing short scripts and adopting the package into our own work.

To help you learn these skills, here is a task chosen from structural engineering.

Task for structural engineers

Objective

It is intended to write a program for the design of cold-formed light-gauge steel structural members using IS 801 - 1975 (Reaffirmed 2010). One important aspect of design of such members is the calculation of the elastic and plastic properties of the sections. A similar requirement arises in the design of steel structural members using IS 800:2007.

Package

Search for a Python package that has the ability to compute geometric roperties of cross-sections.

Package for section properties

The Python package sectionproperties is capable of calculating the elastic and plastic properties of cross-sections, including standard steel sections such as flanged and channel sections.

Explore

Can the package selected package calculate the properties of steel sections with sloping flanges and account for roots of radii? If so, how easy or difficult is it to input the data required for the calculations?

How to test

Do results of the calculations output by using the selected package match those in SP:6(1)-1964? Identify the arguments to balance accuracy with time of execution.

Develop a script

Write a script to read the data from a CSV or Excel file and output the properties exactly as in SP:6(1)-1964.

Test

Compute the elastic and plastic properties of the following sections:

  1. ISMB300
  2. ISMC300

Hint: See the available functions to easily define steel sections.

Task for non-structural engineers

Solution

See snippet Image Manipulation for a complete solution to this task.

Objective

It is intended to develop a program for the manipulation of image files stored in JPG or PNG format. Specifically, at this point of time it is required to determine the size of an image and reduce the size by a specified percentage of its original size, whle maintaining the aspect ratio. Another operation required to be implemented is to convert the image to black and white.

Package

Search for a Python package that has the ability to manipulate image files.

Package for image manipulation

Pillow is a popular image processing package for Python.

Explore

Try the tutorial in the documentation. Does this package have the ability to perform the required operations?

How to test

Do the results output by using the selected package meet the requirements? Can you verify this by getting information of the output image in another image processing application such as IrfanView or GIMP?

Develop a script

Write a script that takes the name of an image file as an input at the command line and asks the user what operation to perform - one of reduce or convert to B/W, and write the image to an output file.

Test

Use any image of your choice and perform the required operations on it and verify the correctness of the operations by opening the modified images in a image software such as IrfanView, GIMP or other similar tools.