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(x): '''square x''' return x**2 def sum_of_squares(x, y): '''sum of squares of x and y''' return square(x) + square(y) z = sum_of_squares(3.0, 4.0) print(z)