<jupyter_start><jupyter_text>Python code samples in "Object Oriented Programming vs. Functional Programming"The Python code snippets in this notebooks are based on this article:https://www.codenewbie.org/blogs/object-oriented-programming-vs-functional-programming, which originally written in `Ruby` language.  Object-Oriented Programming ```rubyclass Employee  def initialize(name, salary)    @name = name    @salary = salary  end  def change_salary(amt)    @salary = @salary + amt  end  def description    "{@name} makes {@salary}"  endend```<jupyter_code>class Employee:
    
    
    def __init__(self, name, salary):
        self.name = name
        self.salary = salary
    
    def change_salary(self, amt):
        self.salary = self.salary + amt
        
    def __repr__(self):
        return "#{} makes #{}".format(self.name, self.salary)<jupyter_output><empty_output><jupyter_text>```rubyemployees = [  Employee.new("Bob", 100000.0),  Employee.new("Jane", 125000.0)]```<jupyter_code>employees = [
  Employee("Bob", 100000.0),
  Employee("Jane", 125000.0)
]
employees<jupyter_output><empty_output><jupyter_text>```rubyemployees.each do |emp|  emp.change_salary(10000.0)end```<jupyter_code>for emp in employees:
    emp.change_salary(10000.0)
employees<jupyter_output><empty_output><jupyter_text>```rubyemployees.each do |emp|  puts emp.descriptionend```<jupyter_code>for emp in employees:
    print(emp)<jupyter_output>#Bob makes #110000.0
#Jane makes #135000.0<jupyter_text>Functional Programming  ```rubyemployees = [  [ "Bob",  100000.0 ],  [ "Jane", 125000.0 ]]```<jupyter_code>employees = [
  [ "Bob",  100000.0 ],
  [ "Jane", 125000.0 ]
]<jupyter_output><empty_output><jupyter_text>```rubyhappier_employees = change_salaries(employees, 10000.0)```<jupyter_code>def change_salaries(employees, amt):
    return [[x[0], x[1] + amt] for x in employees]

happier_employees = change_salaries(employees, 10000.0)
happier_employees<jupyter_output><empty_output><jupyter_text>```rubyhappier_employees.each do |emp|  puts "{emp[0]} makes {emp[1]}"end```<jupyter_code>for emp in happier_employees:
    print("#{} makes #{}".format(emp[0], emp[1]))<jupyter_output>#Bob makes #110000.0
#Jane makes #135000.0
{'fraction_non_alphanumeric': 0.14744459520578923, 'fraction_numerical': 0.051560379918588875, 'mean_word_length': 5.430232558139535, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '336289', 'license': 'MIT', 'n_tokens_mistral': 928, 'n_tokens_neox': 783, 'n_words': 148, 'path': 'FP_OOP/FP v.s. OOP.ipynb', 'repo_name': 'jibanCat/DigitalHumanities', 'size': '2211'}