Title of article

Boot Camp Week 5, Technical Recap

By Mike Bivens | Journey to Web3 | 12 Mar 2022


Week 5 has closed for my Coding Dojo boot camp and this week was all Python for its technical growth, you can follow along or check out the assignments for this stack on its respective repo here in my GitHub. Most of the initial material covered was about recognizing Python syntax, identifying numbers, strings, lists, conditionals, loops, and functions. Some of the new information is below (and as always feel free to check my understanding and challenge me if I'm wrong or not getting quite right).

If you're new here, this blog series is all about my journey from being a coding newbie to working in web3 as a developer. I'm leaving this blog behind to reflect on my experiences and to help others who are looking to follow a similar path. I've learned HTML, CSS, JS, and now I'm starting on a full Python stack. Follow along and feel free to connect if you have any questions!


Python

Tuples

A container for fixed data that cannot be changed, but we can add and slice them together.

tuple_num = (1, 2, 3, 4, 5 )

Dictionaries

A type of set that can store any and as many Python objects as we want. These dictionaries can shrink and grow, be nested, and its values are called using a keyword.

Months = {"Jan": "January", "Feb": "February"}

Default Parameters

Setting default parameters will give us the ability to make some parameters to be optional to the caller of the function.

def current_month(month='', repeat=2):
	print(f"It is {month}\n" * repeat)
current_month()                         # output: It is (repeated on 2 lines)
current_month("January")                # output: It is January (repeated on 2 lines)
current_month(month="February")         # output: It is February (repeated on 2 lines)
current_month(repeat=6)                 # output: It is (repeated on 6 lines)
current_month(month="March", repeat=5)  # output: It is March (repeated on 5 lines)
current_month(repeat=3, month="April")  # output: It is April (repeated on 3 lines)

Python OOP

Once I navigated beyond the initial introduction and the first few assignments to get acquainted with Python, we shifted into understanding Object Oriented Programming (OOP). OOP helps to avoid repeating code for simple problems thus making the maintenance of it easier. This model groups properties and functionalities by object utilizing classes. 

There are four main benefits of OOP;

  • Avoids repeating code
  • Applications become scalable
  • Code is then reusable 
  • Applications become more easily maintained

Classes, Attributes, Methods

Classes are blueprints of objects, and instances are variables of a class that follow those blueprints.  Attributes are the characteristics that are shared by all instances of a class. Methods are the actions that the object can perform. 

class User:
    def __init__(self, name, email):
        self.name = name
        self.email = email

Class/Static Methods 

Class methods, defined with @classmethod, belong to the class and not the instance. 

class month:
    # class attribute
    month_name = "January"
    all_months = []
    # class method to change the name of the month
    @classmethod
    def change_month(cls,name):
        cls.month_name = name

Static methods, defined with @staticmethod, are defined within the class and have no access to instance or class attributes.

class month:
    # class attribute
    month_name = "January"
    all_months = []
    # static methods only have acces to what is passed into it
    @staticmethod
    def can_change_month(_from,_to):
        if _from == _to:
            return False
        else:
            return True

Modules

Modules are python files that implement a set of functions and that are imported.

import urllib.request
response = urllib.request.urlopen("http://www.example.com")
html = response.read()
print(html)

Packages

Packages are collections of modules. These collections are stored in directories that establish a package hierarchy.

from my_package.subdirectory import my_functions

What's Next?

I'm working a bit ahead of the program now so I'm closing this week out having finished the Python Fundamentals. The lectures this week will continue to focus on these materials but I will be working on MySQL lessons. There are a few advanced topics left from Python Fundamentals but I'll come back for those later. I am attempting to include some algo practice to refine my Javascript but that is contingent on stress levels while working on new materials and the progress with the side-projects I am building. 

I've started looking for hackathons in late April or May to participate in that will be beginner-friendly, I am hoping to find a few so I can have some options. Ideally, the hackathon I can participate in will also have a focus on web3 but I won't be limiting myself considering this would be my first event of this kind. 


If you'd like to join the learning community I'm building on Discord for web3, you can find the link for that here. It's a space that I am trying to build for myself and others to share their growing knowledge of all things web3. 

You can also find me here:

LinkedIn | GitHub | Twitter |  My Website 

How do you rate this article?

4


Mike Bivens
Mike Bivens

Blockend Dev | He/Him Founder of WAGMI Squad & TheDrop https://www.msbivens.com/


Journey to Web3
Journey to Web3

I am using this blog to talk about my experiences from pre-software development boot camp towards entering the Web3 ecosystem. I'll share thoughts and what I'm learning, reflect on the journey, and share informational interviews for others to follow along.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.