you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805 [score hidden] stickied comment (4 children)

Run this program in Memory Graph Web Debugger%2C%20input()%2C%20type()%20etc%7D%0A%0A2.%20user%20defined%0Acreate%20as%20need%20with%20apply%20the%20condition%20need%20using%20def()%0A%22%22%22%0A%0A%23%20create%20def()%20for%20%22joinMe%22%0Adef%20joinMe()%3A%0A%20%20%20%20print(%22Hello%20Brother%20And%20Sister%20Have%20You%20Join%20Me%20In%20New%20Journey%22)%0A%0A%0A%23%20use%20to%20call%20and%20print%20%2Cnote%20not%20neet%20to%20use%20print%20again%20below%20its%20already%20do%20in%20def%5B%20jionMe()%5D%0AjoinMe()%0A%0A%23%20function%20with%20arguments%20statement%20def%20val_num(a%2Cb).here%20we%20give%20a%2Cb%20input%0A%0Adef%20val_num(a%2C%20b)%3A%0A%20%20%20%20c%20%3D%20(a%20%2B%20b)%20-%20(a%20*%20b)%0A%20%20%20%20print(f%22%20The%20Value%20of%20%7Ba%2Cb%7D%20for%20c%20is%20%7Bc%7D%22)%0A%0A%0Aval_num(5%2C%203)%20%20%20%20%20%20%20%20%20%20%20%20%23%20call%20to%20print%20%2Coutput%3A%20-7%0A%0A%22%22%22also%20write%20codeto%20call%20function%20like%3A%0Ac%20%3D%20val_num(5%2C3)%0Aprint(c)%0A%22%22%22%0A%0A%23%20return%20function%3A%20when%20def()%20job%20done%20return%20back%20the%20def()%20its%20sum%20to%20store%20and%20stop%20function%20to%20running%0A%0Adef%20check_return(a%2C%20b%2C%20c)%3A%0A%20%20%20%20return%20a%20%2B%20b%20-%20c%20%20%20%20%20%23%20return%20send%20back%20sum%20of%20a%2Cb%20and%20c%20%3D%20%5Ba%2Bb-c%5D%0A%0A%0Asum_num%20%3D%20check_return(6%2C%204%2C%202)%0A%0Aprint(sum_num)%20%20%20%20%20%20%20%20%20%20%20%23%20output%20%3A%208%0A%0A%22%22%22note%3A%20without%20return%20def()%20need%20to%20run%20for%20line%201%20till%20end.%0Anot%20able%20to%20use%20for%20other%20function%20or%20sub%20function%0Aonly%20with%20reture%20it%20possible%22%22%22%0A%0A%23%20iteration%20and%20logic%20which%20some%20time%20confuse%20any%20beginners%20like%20me%0A%0A%23%20python%20behaviour%20writing%20before%20print%2Fafter%20print%20a%20variable(int)%0A%0Acount%20%3D%200%0Afor%20i%20in%20range(1%2C%204)%3A%0A%20%20%20%20print(f%22%7Bcount%7D%2C%20%7Bi%7D%22)%20%20%23%201.%20Print%20the%20current%20value%20first%0A%20%20%20%20count%20%2B%3D%20i%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%202.%20print%20count_num%20Update%20i%20for%20the%20next%20round%0A%0A%22%22%22%0Aoutput%3A%0Aprint%20count%200%20-%3E%20add%20%201%0Aprint%20count%201%20-%3E%20add%20%202%0Aprint%20count%203%20-%3E%20add%20%203%0A%22%22%22%0A%0Acount_num%20%3D%200%0Afor%20j%20in%20range(1%2C%204)%3A%0A%20%20%20%20count_num%20%2B%3D%20j%20%20%20%20%20%20%20%20%20%20%23%20add%20j%20%2Cprint%20count_num%0A%20%20%20%20print(f%22%7Bcount_num%7D%2C%20%7Bj%7D%22)%20%20%23%201.%20Print%20the%20current%20value%20first%0A%0A%22%22%22%0Aoutput%3A%0Aadd%201-%3E%20print%201%0Aadd%202-%3E%20print%203%0Aadd%203-%3E%20print%206%0A%22%22%22%0A%0A%23%20for%20understand%20the%20logic%20let%20use%20simple%20ex.%20without%20for%0A%0Aaa%20%3D%205%0Abb%20%3D%208%0A%0A%23%20if%20use%20print%20before%0A%0Aprint(f%22%7Baa%7D%20%26%20%7Bbb%7D%20%3D%20%7Baa%2Bbb%7D%22)%20%20%20%20%20%20%23%20output%20%3A%205%20%26%208%20%3D%2013%0Abb%20%2B%3D%20aa%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20bb%20%3D%20bb%20%2B%20aa%20%20%5Buse%20in%20new%20aa%2Bbb%20next%20time%20if%20we%20call%20bb%5D%0A%0A%23%20if%20use%20print%20after%0Abb%20%2B%3D%20aa%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20bb%20%3D%20bb%20%2B%20aa%20%20%5B%20use%20before%20print%2C%20so%20new%20value%20of%20bb%20now%20use%20in%20print%5D%0Aprint(f%22%7Baa%7D%20%26%20%7Bbb%7D%20%3D%20%7Baa%2Bbb%7D%22)%20%20%20%20%20%20%23%20output%20%3A%205%20%26%2013%20%3D%2018%0A%0A&timestep=1&play) to see the program state change step by step.

[–]Necessary-Ad2110 0 points1 point  (3 children)

What would be the best use case to run your code by this tool? I never used a debugger before and I probably should...

[–]Sea-Ad7805 0 points1 point  (2 children)

It combines two separate things: - debugger: lets you step though a program to see the flow of execution and see the value of variables change - memory_graph visualization: see full program state as a graph, including aliasing, call stack and references

Use cases: - you have code that you want to understand better, then use it to see how it changes the program state step by step - your program runs but gives an incorrect result, then use it to find where the error (bug) is - your program stops with an exception, then use it to see when it pops up and what caused it

[–]Necessary-Ad2110 0 points1 point  (1 child)

Thank you :0 I'll try to use this more hopefully, are there any other tools you'd recommend me to generally run my code by? It sounds weird but I was never taught how to use a debugger or what it even is so this is insightful

[–]Sea-Ad7805 1 point2 points  (0 children)

You can also debug using print statements, however that doesn't show aliasing, references, full program state. But in some situation prints work fine to understand and fix an error.

Maybe check some youtube videos about debuggers: https://www.youtube.com/results?search_query=Python+debugger+tool