How to learn a Programming Language

Everything needs a little commitment and a care.

Programming is a beautiful superpower that one should have which is about instructing a computer to use its resources accordingly. So, when it comes to the starting point of programming, there are two types of groups.

  • people who are beginners to programming

  • people who are not beginners to programming but new to learning of programming

Here, each group's learning curve may be different but the concepts and terms are the same. So each concept needs to be learned with a conscious mind. So, I am going to divide the programming concepts into two branches programming foundations and paradigms.

Programming foundations

  • Variables

  • Data types

  • Comments

  • Operators

  • Conditional Statements

  • Loops (Iterators)

  • Functions

Programming paradigms

  • OOP - Object Oriented Programming

  • Functional programming

  • etc.

Now Let me go through each concept and term one by one and I will explain these branches using the Python programming programming language.

Variables and Data types

  • Think of variables as named boxes that store information you want to use later.

  • Each box has a unique name ( like my_age, favourite_colour, total_score ).

  • You put different kinds of stuff in these boxes, like numbers, words, or true/false values.

  • So, data type tell you what kind of stuff can go in a variable box.

age = 25 # Integer
height = 5.8 # Floating point
name = "Alice" # String
is_student = True # Boolean

Operators

  • Operators are like tools that let you do things with the stuff in your variable boxes.

  • So, there are several types of operators as Arithmetic, Relational, Logical, Bit-wise and Assignment (=).

  • Arithmetic operators are for adding, subtracting, multiplying, dividing etc.

  • Relational operators are for finding out relation between two values: whether they are equal, greater than or equal like wise.

  • Logical operators are for combining two conditional statements.

    ( example below. : When a person over 18 and has a ticker he or she can enter the concert. )

  • Bit-wise operators are for working with binary numbers.

  • Assignment operator is for the assign values to the variables.

addition = 10 + 5 # output -> 15
substraction = 12 - 10 # output -> 2
multiplication = 4 * 3 # output -> 12
division = 12 / 4 # output -> 3.0
modulo = 12 % 4 # output -> 0
is_equal = (5 == 5) # output -> True

# Use of logical operator below.
if age >= 18 and has_ticket:
    print("You can enter the concert.")

Conditional Statements

  • Conditional statements are like decision points in your code.

  • They let you make choices based on certain conditions being true or false.

if age >= 18:
    print("You are an adult.") # If age is greater than 18 it will print this.
else:
    print("You are a minor.") # If age is less than 18 it will print this.

Loops (Iterators)

  • Loops or in the technical term "The Iterators" are repeaters that let you do something over and over again.

  • They are useful for tasks that needs to happen multiple times.

  • When it comes to Loops there are three main types: for, while, do-while.

  • We use for loop when we know the number of repetitions.

  • We use do-while loop when we know the number of repetitions must be higher than one. ( > 1 )

  • We use while loop when we do not know the number of repetitions.

for i in range(5):
    print(i)
# 0
# 1
# 2
# 3
# 4

Functions

  • It is a way of organizing the code under common basis which make it reusable.

  • To use the function you need to call the function.

  • In a function the values that are passed to the function called arguments ( eg: Alice ) and the placeholders called parameters ( eg: name ).

def greet(name):
    print(f"Hello, {name}!")

greet("Alice") # Calling the function. 
# output -> Hello, Alice

Programming paradigms

Programming paradigm is a way of solving a problem using a programming structure. Some programming languages comes with predefined programming paradigms like Java (Object Oriented Programming), C (Structured Programming) but programming languages like Python on the other hand gives the flexibility to the user.

Below I mentioned Python's ability to go with both functional and OOP programming paradigms. It does not need know every programming paradigm but knowing Object Oriented Programming Paradigm would be beneficial for you.

  • OOP - Object Oriented Programming

      class Person:
          def __init__(self, name):
              self.name = name
    
          def greet(self):
              print(f"Hello, {self.name}!")
    
      person = Person("Bob")
      person.greet()
    
  • Functional programming

      def square(x):
          return x * x
    
      numbers = [1, 2, 3, 4]
      squared_numbers = list(map(square, numbers))
    

Awesome! Now, the real fun begins. Hone your skills through practice, embrace the learning curve, and discover the full potential of your programming superpowers.

Summary

Master the Essentials:

  • Variables & Data Types: Understand how to store and categorize information within your code.

  • Operators & Logic: Learn the tools to manipulate data and make informed decisions within your program.

  • Conditional Statements & Loops: Control the flow of your code with branching paths and repetitions.

  • Functions: Organize and reuse blocks of code for efficient development.

Explore Programming Paradigms:

  • Object-Oriented Programming (OOP): Discover how to model real-world objects and their interactions.

  • Functional Programming: Embrace a declarative approach focused on pure functions and data transformations.

  • Python's Flexibility: Utilize Python's adaptability to choose the paradigm that best suits your needs.

Embrace the Journey:

  • Practice is Key: Actively code and experiment to solidify your understanding.

  • Enjoy the Learning Curve: View challenges as opportunities for growth and seek help when needed.

  • Unlock Your Potential: With dedication and this guide as your companion, you'll soon be building your own programming magic.