Python Forum
Tracing a multiplication table w/ Python trace()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tracing a multiplication table w/ Python trace()
#1
I'm interested in understanding how to implement Python's trace module to follow the execution of a multiplication table and print its annotated results.

I researched Python documentation and internet sources related to trace() and the multiplication program to figure out how use the trace module, but I came up empty-handed.

import sys
import trace

tracer = trace.Trace(
    ignoredirs=[sys.prefix, sys.exec_prefix],
    trace=0,
    count=1)

def print_multiples(n, high):
    for i in range(1, high+1):
        print(n * i, end="   ")
    print()

def print_mult_table(high):
    """ Return a multiplication table with n rows and columns."""
    for i in range(1, high+1):
        print_multiples(i, high)

print_mult_table(7)

r = tracer.results()
r.write_results(show_missing=True, coverdir=".")
The program outputs a multiplication table, so there are no error messages. I'm using Win 8.1, Python version 3.7.3 (64-bit), and an Intel core i7-based system.

Any assistance on how the integrate the trace module with the multiplication table is appreciated.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiplication Table code alexsendlegames100 3 1,366 Jun-06-2022, 09:45 AM
Last Post: Gribouillis
  Try to solve GTG multiplication table problem. Frankduc 6 2,012 Jan-18-2022, 08:26 PM
Last Post: Frankduc
  Need help with my Python code (Multiplication) NeedHelpPython 2 1,684 Oct-04-2021, 12:09 PM
Last Post: Pedroski55
Lightbulb trace library xxxlabradorxxx 1 1,148 Oct-01-2021, 11:30 PM
Last Post: Larz60+
  question about flask tracing javidr 0 1,084 Aug-04-2021, 09:22 PM
Last Post: javidr
  List conversion and multiplication johnkyp 5 3,172 Jan-02-2020, 08:20 AM
Last Post: perfringo
  Matrix Multiplication Issue VIJENDRA 1 1,866 Dec-19-2019, 06:16 PM
Last Post: Gribouillis
  Multiplication between a list and a variable doug2019 2 2,170 Oct-08-2019, 04:10 AM
Last Post: doug2019
  Multiplication Table number margins CJ707 4 2,439 Sep-18-2019, 02:16 PM
Last Post: CJ707
  multiplication by successive addition Zebrol 1 3,521 Sep-14-2019, 05:37 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020