Storing data in a dictionary
The surface you see below is called circular paraboloid:
It can be described by the following equation: $$ \frac{x^2}{a^2} + \frac{y^2}{a^2} = z $$ Let's set the coefficient \(a\) to 1. Therefore, the radius at each cut will be equal to \(\sqrt{z}\).
Your task is to create a dictionary that stores the mapping from the pair of coordinates \((x, y)\) to the \(z\) coordinate (the lists storing considered ranges for \(x\) and \(y\) are given: range_x
and range_y
, respectively).
Diese Übung ist Teil des Kurses
Practicing Coding Interview Questions in Python
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
circ_parab = dict()
for x in range_x:
for y in range_y:
# Calculate the value for z
z = ____
# Create a new key for the dictionary
key = ____
# Create a new key-value pair
circ_parab[____] = ____