Tax-Free* | 18-Month Warranty | 30 Day Returns Guaranteed.

6.3.5 Cmu Cs Academy Site

def main(): w = 10 h = 5 area = calculate_area(w, h) Label(f'Area = area', 200, 200, size=24, bold=True)

# Function: calculate_area # Parameters: width (int or float), height (int or float) # Returns: area (int or float) def calculate_area(width, height): area = width * height return area Key : Use return , not print() . Returning sends the value back to the caller. Step 3: Call the function in main() or global scope def main(): rect_area = calculate_area(10, 5) # Now rect_area holds 50 Step 4: Use the returned value Often they ask you to display it:

Label(f"Area: rect_area", 200, 200, size=20) from cmu_graphics import * def calculate_area(width, height): return width * height

Firmware Download

6.3.5 Cmu Cs Academy
6.3.5 Cmu Cs Academy

6.3.5 Cmu Cs Academy Site

  • Release time: 2024-06-28 17:45:21
  • Version: ETH_VT-EDA121
  • File size: 1.79M
  • 1. Fix some bugs.