• 0 Posts
  • 315 Comments
Joined 1 year ago
cake
Cake day: June 10th, 2023

help-circle
rss













  • A lot of responses here so I’ll suggest a different approach. You can watch your python code execute line by line using a debugger. That might help with understanding how it all works.

    def my_sum(list):
        result = 0
        for number in list:
            result += number
        return result
    
    my_list = [1, 2, 3, 4, 5]
    list_sum = my_sum(my_list)
    print(list_sum)  # Prints 15
    

    If you run the above code line by line in a debugger, you’ll see that when it gets to list_sum = my_sum(my_list) the program will jump into the function my_sum(list) where “list” is a variable holding the value of “my_list”. The program continues line by line inside of the function until it hits the return result statement. The program then returns to the line it was at before jumping into the function. “my_sum(my_list)” now has an actual value. It’s the value that the return statement provided. The line would now read list_sum = 15 to python.

    A debugger shows you which lines get executed in which order and how the variables update and change with each line.

    Just a note: python has a built-in sum() function you could use instead of writing your own my_sum() function, but a debugger won’t show you how built-in functions work! They’re built into the language itself. You’d need to look up Python’s documentation to see how they actually function under the hood.





  • In case anyone wanted to know a bit more. He was the founder of the American Railway Union, one of America’s first industrial unions. As leader, he organized a stike against the Pullman factory that resulted in its own factory workers, who were not ARU members, to strike. The strike was because factory workers had their wages reduced but their rents (which they paid to the company they worked for) were not. Engineers and conductors for the company continued to work, so Debs had the striking factory workers block railways. That caused the government to send in the army to break up the union and jail Debs along with other union and strike leaders.

    While in jail, Debs read socialist political literature and founded several socialist political parties on his release. Debs gave many political speeches that upset the government, but one where he urged listeners to dodge the WWI military draft, because the proletariat shouldn’t fight the battles of the rulling class, caused him to be jailed once again for sedition. It was this time in jail that he ran for office.

    https://en.wikipedia.org/wiki/Eugene_V._Debs