Login using Social Account
     Continue with GoogleLogin using your credentials
Now we know how to assign the value to a variable. Let's see how to use variables in the code and how variables are useful. Let's calculate the area of a rectangle with height as 50 and width 40. The formula for the area of a rectangle is -
Area of rectangle = height * width
Let's write the code. Define two variables height
and width
and give them the value of 50
and 40
respectively and then apply the formula
height = 50
width = 40
area_of_rectangle= height * width
print(area_of_rectangle)
Run the above code in the Jupyter notebook on the right-hand side. It should give print area as 2000
height
variable to 60
width
variable to 40
new_area_of_rectangle
variable2400
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Loading comments...