Prints the multiplication table of a given number till the given number of terms >>> print(multiplication_table(3, 5)) 3 * 1 = 3 3 * 2 = 6 3 * 3 = 9 3 * 4 = 12 3 * 5 = 15 >>> print(multiplication_table(-4, 6)) -4 * 1 = -4 -4 * 2 = -8 -4 * 3 = -12 -4
(number: int, number_of_terms: int)
| 1 | def multiplication_table(number: int, number_of_terms: int) -> str: |
| 2 | """ |
| 3 | Prints the multiplication table of a given number till the given number of terms |
| 4 | |
| 5 | >>> print(multiplication_table(3, 5)) |
| 6 | 3 * 1 = 3 |
| 7 | 3 * 2 = 6 |
| 8 | 3 * 3 = 9 |
| 9 | 3 * 4 = 12 |
| 10 | 3 * 5 = 15 |
| 11 | |
| 12 | >>> print(multiplication_table(-4, 6)) |
| 13 | -4 * 1 = -4 |
| 14 | -4 * 2 = -8 |
| 15 | -4 * 3 = -12 |
| 16 | -4 * 4 = -16 |
| 17 | -4 * 5 = -20 |
| 18 | -4 * 6 = -24 |
| 19 | """ |
| 20 | return "\n".join( |
| 21 | f"{number} * {i} = {number * i}" for i in range(1, number_of_terms + 1) |
| 22 | ) |
| 23 | |
| 24 | |
| 25 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected