Python | CSV and Excel exercise | Create an Excel workbook containing a simple calculator

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

You can learn how to do this exercise if you attend the course listed below!

Software ==> Python  (25 exercises)
Version ==> Latest version
Topic ==> CSV and Excel  (2 exercises)
Level ==> Relatively easy
Classroom ==> Python programming
Online ==> Python programming

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Your task for this exercise is to create this simple calculator in Excel:

Calculator

Note that you won't be able to do any formatting (or at least, this exercise certainly won't ask you to).

 

To do this import the openpyxl module, then create a new workbook, populate it as shown, save it and close it.  Some syntax to help you:

Operation How to do it
Create a new workbook workbook_variable = openpyxl.Workbook()
Referring to the current sheet worksheet_variable = workbook_variable.active
Changing a cell value worksheet_variable.cell(row,col).value = ?
Saving a workbook workbook_variable.save(file_name_here)
Closing a workbook workbook_variable.close()

Check that your Excel workbook has been created OK (and that your calculator works!), then close your program down.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post