Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.) A function triples() returning a list of all (positive) integer Pythagorean triples for all hypotenuse values up to, and including, some value. 2.) A

1.) A function triples() returning a list of all (positive) integer Pythagorean triples for all hypotenuse values up to, and including, some value.

2.) A chainable function say() that accepts one string per call, but when called without arguments, returns the words previously passed, in order, separated by a single space.

h1_test.py

import re

import pytest

from h1 import (triples, say)

def test_say():

assert say() == ''

assert say('hi')() == 'hi'

assert say('hi')('there')() == 'hi there'

assert say('hello')('my')('name')('is')('Colette')() == 'hello my name is Colette'

def test_triples():

assert triples(0) == []

assert triples(5) == [(3, 4, 5)]

assert set(triples(40)) == set([(3, 4, 5), (5, 12, 13), (6, 8, 10), (7, 24, 25), (8, 15, 17),

(9, 12, 15), (10, 24, 26), (12, 16, 20), (12, 35, 37),

(15, 20, 25), (15, 36, 39), (16, 30, 34), (18, 24, 30),

(20, 21, 29), (21, 28, 35), (24, 32, 40)])

** Please implement the above two functions in Python and name the source file as h1.py. A test file h1_test.py is provided above! You need to install the pytest before compiling the files.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago