Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pytestmodify multiply.py Write a function called multiplication_table that takes a width, height, & scaling factor as parameters and returns a two-dimensional array multiplication table scaled

Pytestmodify multiply.py

image text in transcribed

image text in transcribed

image text in transcribed

Write a function called multiplication_table that takes a width, height, & scaling factor as parameters and returns a two-dimensional array multiplication table scaled by the scaling factor. You should not be using any functions other than range in implementing your solution. Example calls Returns print_2D (multiplic ation_table (5, 3, 1)) [1, 2, 3, 4, 5] [2, 4, 6, 8, 10] (3, 6, 9, 12, 15] print_2D (multiplic ation_table (5, 3, 2)) [2, 4, 6, 8, 10] [4, 8, 12, 16, 20] [6, 12, 18, 24, 30] M 4 00 multiply_test.py * 1 from multiply import multiplication_table 2. 3 E def test_5_3_1(): 4 expected = [ [1, 2, 3, 4, 5], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15] ] 5 assert ) multiplication_table(5, 3, 1) == expected 6 7 Edef test_5_3_2(): 8 expected = [ [2, 4, 6, 8, 10], [4, 8, 12, 16, 20), [6, 12, 18, 24, 30] ] 9 assert multiplication_table(5, 3, 2) == expected 10 11 Edef test_25_3_10(): 12 expected = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250], \ 13 [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500], 1 14 [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600, 630, 660, 690, 720, 750]] 15 assert multiplication_table(25, 3, 10) == expected 16 17 multiply.py * 9 # and returns a two-dimensional array multiplication 10 # table scaled by the scaling factor. 11 # You should not be using any functions other than range. 12 def multiplication_table(w, h, s): 13 return [ ] 14 15 def print_2D(6): 16 for i in range(len(b)): 17 print(b[i]) 18 19 def main(): 20 print("5 3 1:") print_2D(multiplication_table(5, 3, 1)) 22 print("5 3 2:") 23 print_2D(multiplication_table(5, 3, 2)) 24 25 # Don't run main on import 26 if __name_ '__main_": main() 28 29 | 21 27

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

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions