- Access exercises (91)
- C# exercises (79)
- Excel exercises (278)
- Power Apps exercises (13)
- Power Automate exercises (18)
- Power BI exercises (139)
- Power Platform exercises (157)
- Python exercises (28)
- Report Builder exercises (141)
- SQL exercises (198)
- SSAS exercises (51)
- SSIS exercises (46)
- SSRS exercises (99)
- VBA exercises (85)
- Visual Basic exercises (46)
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 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:
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.