Speak Like a Programmer: 10 Terminologies You Should Know and Use As a Python Programmer

Speak Like a Programmer: 10 Terminologies You Should Know and Use As a Python Programmer

Hi there!

Have you ever been in the midst of other programmers, possibly at a tech meetup, a tutorial class, an online forum, or anywhere else and you keep hearing some terms you are not familiar with but you don't want to look like a complete novice so you don't ask questions and just nod along?

Every programmer at some point in their career must have found themselves in such a scenario.

There's no need to be embarrassed. Programmers do not necessarily need to be geniuses but we are expected to be smart.

So a smart programmer would always update his knowledge and try to become familiar with his tools.

In this article, we will look at 10 terminologies a python programmer should know and use when having conversations with his pairs.

The Terminologies

1. Concatenation

This simply means joining two or more string characters together. For example:

print("snow" + "ball")

# output
>>> snowball

We merge two strings 'snow' and 'ball' to give 'snowball'. In Python, the plus sign operator + is used to concatenate strings. However, in other programming languages, other operators like & and | are used.

2. Initialization

Derived from the word 'initial' meaning 'beginning' or 'starting', initialization simply means assigning a starting value to a variable.

Initialization is done at the point of creating the variable. For example:

# Let's initialize the variable book
book = 2

3. Instantiation

Instantiating a class is (simply) creating a copy of the class which inherits all the variables (attributes) and methods (like functions) of the class - Tutorialspoint.com. To demonstrate, let's create a class with the name 'Human' as shown below:

# A simple class 
class Human:

    def __init__(self, name): 
        self.name = name  

    def speak(self):
        print(f"Hi, My name is {self.name}")

Then, we can create a copy of this class by doing:

person = Human("George")

This is what instantiation is. We have instantiated person (an object) from the Human class. Notice that the object person inherited the attribute (name) and the method (speak) of the Human class as shown below:

print(person.name)

person.speak()

The output should look like this when you run the code:

>>> George
>>> Hi, My name is George

So person has a name and it can speak. Smooth right?

4. Types of brackets

We know them and we use them all the time.

But not many people know what to call them when discussing with fellow programmers, or giving a tech talk.

Hence the need for their inclusion in this article.

The different types of brackets used in Python are parentheses or "round brackets" ( ), "square brackets" or "box brackets" [ ], braces or "curly brackets" { }.

These brackets are unique to different data types and structures in Python.

So the next time you're talking with a fellow programmer or teaching your mentees, do well to call them by their proper name.

5. Writing Clean Code

Whenever someone tells you that your code is not clean, do not take it as an insult, neither should you think you are to apply a cleaning substance to your code. (lol...)

What writing clean code actually means is that your code should be readable to other programmers, it should be reusable, and there should be no duplication of code blocks.

This article summarizes the three principles of a clean code. They are Readability, Maintainability, and Extendability.

Click on the link to read more about it.

6. Hard Coding

If you have been following up with the articles on this blog, you probably know what hard coding is already. I wrote a whole article about it with a practical example. You should read about it here.

In simple terms, Hard-coding is when you fix a value for a variable directly inside your code (or source code).

Most programmers feel it's not a good practice but there are some cases where it is required. You will find more information when you read the aforementioned article.

7. Instance variables Vs Class variables

Class Variables are variables that are shared by all instances of a class while instance variables can be unique for each instance of a class.

What does this mean? Let's use our Human class to explain.

class Human:
    # a class variable
    heart = 1

    def __init__(self, name):
        # an instance variable 
        self.name = name  

    def speak(self):
        print(f"Hi, My name is {self.name}")

In the code block above, we created two variables for Human: heart and name.

heart is a class variable while name is an instance variable. Notice how when we run the code below, the value for heart remains the same for the two objects we created while the value for name changes.

# instantiate the first object
person_1 = Human("George")

# instantiate the second object
person_2 = Human("Stephanie")

# check how many hearts they both have
print(f"How many heart does {person_1.name} have? : {person_1.heart} ")

print(f"How many heart does {person_2.name} have? : {person_2.heart} ")

The output:

>>> How many hearts does George have? : 1
>>> How many hearts does Stephanie have? : 1

So the name variable differs for each person created while the heart variable remained the same.

Read more about class and instance variables here and here.

8. Parameters Vs Arguments

According to w3schools.com, the terms parameter and argument can be used for the same thing: information that is passed into a function.

However, a parameter is the variable listed inside the parentheses () when the function is defined while an argument is a value that is sent to the function when it is called.

This also applies to methods. Methods receive parameters on definition and are sent an argument (or arguments) when called.

Still using the Human class as an example:

class Human:

    def __init__(self, name): 
        self.name = name  

    def speak(self, sentence):
        print(sentence + self.name)

The speak method has the parameter sentence listed in its parenthesis. When we create an object from Human and call the speak method, we have to pass to it, an argument that will be the value for the sentence parameter.

person_1 = Human("George")

person_1.speak("Hi, My name is ")

Notice in the code above, "Hi, My name is " is the value for sentence. Then sentence is concatenated with name to give this as output:

>>> Hi, My name is George

Alright then, do read more about it here

9. Functions Vs Methods

One reason why these two look so familiar is that they are both defined using the def keyword. They even have parenthesis () behind them but they are not the same.

Functions are created outside a class while methods only exist in a class. This means that functions are called without a prefix and a dot (.) but methods are prefixed by their object name and a dot(.).

For example, the .speak() method in Human can be called this way:

person_1.speak("Hi, My name is ")

But not this way:

speak("Hi, My name is ")

I wrote a 5 mins article with examples about functions and methods including their differences. Read it here

10. Local variable vs Global variable

Let's explain with the example below:

first_number = 4

def sum():
    second_number = 6
    print(first_number + second_number)

In the code snippet above, we created two variables, first_number and second_number.

first_number was created outside the function sum() while second_number was created inside of sum().

sum() is a function that will compute the addition of the two variables and print out the result.

Add the code below to the one above and run it

sum()

The output:

>>> 10

Cool! So 10 is the sum of the two variables.

Now, what if we wanted to compute the sum of the two variables outside the sum() function, and we do something like this:

first_number = 4

def sum():
    second_number = 6
    print(first_number + second_number)    

# try to compute the sum of the two variables outside the sum function
print(first_number + second_number)

The output of this code snippet above should be:

>>> NameError: name 'second_number' is not defined

We got an error. The error says that second_number is not defined.

But how can it be when we can clearly see that it was defined inside the sum() function.

The Python interpreter should just go inside the function and make use of it right?

Nope. The interpreter doesn't work that way.

When a variable is defined inside a function, it can only be used inside that function and it doesn't exist outside the function. The interpreter sees these types of variables as Local variables.

But a variable defined outside a function can be used anywhere both inside and outside a function. They are called Global variables.

Therefore, first_number is a global variable while second_number is a local variable.

Most of the terms mentioned in this article are also applicable in other programming languages as well. There may just be a slight difference in meaning or representation.

Okay! We are done...

There are still many more terminologies used in Python and other languages but these, listed here, are the ones most beginner python programmers would come across.

Make sure to do further research and update your knowledge of Python in other to impress that friend, colleague, boss, or even mentee of yours.

Feel free to mention any other terminology you know, that is not listed here, in the comment section below.

Please react to this post as well by clicking on the thumbs up button.

Don't forget to subscribe using the subscription form above this article. You'd be the first to be notified when a fresh new article drops ๐Ÿ˜€

Thank you!

Photo by hitesh choudhary from Pexels

ย