Introduction to Programming with Python

CO₂ cost sharing calculator

final project by A. Krüger



The CO₂ Cost Sharing Act: What is it exactly?

The Carbon Dioxide Cost Sharing Act has been in force in Germany since January 1, 2023. The aim of the law is to ensure a fair distribution of CO₂ costs between landlords and tenants. The distribution of costs for CO₂ pricing depends on the consumption and the type of property.
For residential buildings and buildings used primarily for residential purposes, a ten-stage model is planned based on actual consumption.
The "CO₂ cost calculator" program makes it possible to calculate the share in euros for tenants and landlords, depending on the fuel, the annual consumption in kWh (kilowatt hours) and the total living space of the building.

Explanation of the program

The program has several areas:

Inputs: The user fills in the fields and selects the relevant options. When the user click on the "Calculate" button, the program will perform the calculations in the background.

Display of the result: Once the calculations have been carried out, the software displays the results in this area.

Options: The user has the option of printing, saving or deleting the result in order to carry out a new calculation.

Explanation of the calculation

First, the fuel must be selected (gas, district heating or heating oil). In the next steps, the user hast to enter the kilowatt hours consumed,the CO₂ fuel factor and the total living space of the building.
The user then has to choose between residential and commercial buildings. If the building is a listed building (protected monument), the user has the option of choosing between a reduction of 50% or 100%, depending on the information provided by the monument conservation authority.

As soon as the user press the "calculate" button, all the information is transferred to the form. The calculation is performed in the background as follows: Depending on the type of fuel, a specified factor must be used by law, which is multiplied by the kilowatt hours. The result is expressed in kilograms. These are divided by the living space to obtain the CO₂ emissions per m².

The CO₂ price is calculated at the same time. In 2023, the price / kg is set at 0.03 Euros. The calculated kg are multiplied by 0.03 and the VAT of 7% applicable for 2023 is added.

The final step is to determine what percentage of the CO₂ costs will be charged to the tenant and the landlord. For a commercial building, 50% is applied for each one; for a residential building, a 10-stage model is used.

If the user has chosen monument protection, landlords determined share of the costs will be reduced by 50 or 100% and charged to the tenant. The program finally displays the total costs and the shares in percent and Euros of the tenant and the landlord.


This software is proprietary and subject to the terms of use of the publisher. Any reproduction, distribution, or modification of the software without the express permission of the publisher is prohibited.


Video presentation


This was CS50P!

Thanks to David J. Malan for the great course

It took me 6 months, alongside a full-time job, to complete the introductory course and the project. The difference to many other courses that the internet has to offer is that with David J. Malan you learn to think like a programmer. It is not enough to know the programming language. I can only warmly recommend this course and thank David J. Malan for it.

CS50P Harvard School of Engineering and Applied Sciences

CS50P certificate A-Krueger



For further information about the program or the course,
please contact Mrs. A. Krueger: info[at]a-krueger.eu