Python 1.5

Rectangle Area Calculator

  • Fully automatically graded on code quality, style, structure and functionality
  • Students write their solution in an online IDE in their LMS
  • Check for Python code plagiarism


  • To have learned about print statements.
  • To have learned about python arithmetics.

Learning goals:

  • Get familiar using variables in Python.
Get access to an autograder, plagiarism checker and online IDE for this assignment now!


Until now, we have mostly worked with values, like strings and numbers (for instance integers), that we printed directly to the screen. One of the most powerful features of programming languages is the ability to save a value with a name, which makes it a variable. Now that you can define variables, we can start to make our formulas dynamic and dependent on the values of the variables.

For our first formula, we will define two variables that we need in order to calculate the area of a rectangle: the length and the width. These variables should be named exactly `length` and `width` in your code.

Your task is to assign values to these variables (in a so-called assignment statement) and use them in a formula to print out the rectangle area. Write this in a program called ``.

After creating this script, please note that you can simply change the values of these variables to produce different outputs. In our example below, we have a width of `10` and a length of `33`.

Example usage:

-!- CODE language-bash -!-$ python3

Learn more:

Start teaching Python now

CodeGrade is your virtual teaching assistant for your coding classroom. You teach, CodeGrade takes care of the rest.

With our 40+ built-in fully automatically graded Introduction to Python assignments for university-level courses, you can start teaching Python at your institution with confidence now. Or, scale your classroom with CodeGrade's tools.

Book a personal 30-minute demo now and we'll show you how to get started with CodeGrade in less than 1 hour!

Book a demo now!

Happy educators

  • Educators who use CodeGrade have less stress.
  • Educators who use CodeGrade have happier and more successful students.
  • Educators who use CodeGrade have a simpler teaching workflow.

Schedule a personalized tour of CodeGrade today.