Skip to content

Latest commit

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

PrintState

Python script to print program state of python functions

Example - Bubblesort

Given the following bubblesort program

defbubblesort(sortme):
offset=1whileTrue:
swapped=Falseforiinrange(len(sortme)-offset):
ifsortme[i] >sortme[i+1]:
sortme[i], sortme[i+1] =sortme[i+1], sortme[i]
swapped=Trueoffset+=1ifnotswapped:
returnsortmeif__name__=="__main__":
bubblesort([7,8,3])

This will generate the following svg image:

Bubblesort flow

Example - Findmax

Given the following find max program (with bug):

deffind_max(num1, num2, num3):
max_num=0ifnum1>num2andnum1>num3:
max_num=num1elifnum2>num1andnum2>num3:
max_num=num2elifnum3>num1andnum3>num2:
max_num=num3returnmax_numif__name__=="__main__":
find_max(3,3,5)

This will generate the following svg image:

Find maximum

About

Python script to print program state of python functions

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages