Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
10327 views
ubuntu2004
Kernel: Python 3 (system-wide)

Exercise 22.1

  1. Write a function called square() that takes a number as an argument and returns the square of that number.

  2. Write a function called sum_of_squares() that takes two numbers as arguments, calls square() for each of them separately and returns the sum of their squares.

def square(a): number = a**2 return number def sum_of_squares(a, b): sum = square(a) + square(b) return sum z = sum_of_squares(3.0, 4.0) print(z)
25.0