Blessing Aliu
Blessing's Coding Journey

Blessing's Coding Journey

2nd session: Fundamentals of coding with Python continued (Syntax and lists)

Photo by Artturi Jalli on Unsplash

2nd session: Fundamentals of coding with Python continued (Syntax and lists)

Software development and System Architecture Bootcamp

Blessing Aliu's photo
Blessing Aliu
·Mar 24, 2022·

3 min read

Table of contents

  • Python Syntax (Important bits)
  • Python Operators summarised
  • Python Data Types continued

Today was very comprehensive, we covered overall Python syntax which I will outline below in a very concise way. I also learnt about Lists as a ordered Data structure, with associated built-in methods. Next week we move on to Functions, if statement, for and while loops.... exciting stuff!

Python Syntax (Important bits)

  • Indentation
  • Variables (case-sensitivity) - camelCase, snake_case and PascalCase
  • Python comments
  • Casting
  • Global and local scoping


# This is a single line comment 

This is the first comment
This is the second


  • Changing the data type of a variable (from int to str)
var_name = int(var_name)

// output int

Global Scope vs Local Scope

  • Scope has to do with where you can access your variables

The explanation is that

  • Local scope includes all variables declared inside a function. A local variable is only accessible where it’s declared.
  • Global scope includes variables declared outside of the function. This variable can be accessed anywhere within the script.

Python Operators summarised

  • Arithmetic operators (+, -, , /, %, *, //)
  • Comparison operators (==, =!, >, <, >=, <=)
  • Logical operators (AND [both sides true], OR [one side true], NOT [no side true])
  • Membership operators to check whether a value or variable exists in a sequence (string, list, tuples, sets, dictionary) or not(in, not in)

Python Data Types continued

Lists (and their methods)

  • Lists are used to store multiple items in a single variable [ ].
# This is an example of a list
names = ['David', 'Blessing', 'Sarah', 'Dayo']
# Ouputs ['David', 'Blessing', 'Sarah', 'Dayo']

- copy()    Returns a copy of the list (creates a new list)
# Ouputs ['David', 'Blessing', 'Sarah', 'Dayo']

- count()    Returns the number of elements with the specified value
# Outputs 1

- index()    Returns the index of the first element with the specified value
# Outputs 0

- extend()    Add the elements of a list (or any iterable), to the end of the current list
# You can use multiple values to extend the list
new_elements = ['Bayo', 'James', 'Solomon']
# Outputs ['David', 'Blessing', 'Sarah', 'Dayo', 'Bayo', 'James', 'Solomon']

- append()    Adds an element at the end of the list (modifies the original list)
# You can only insert one value at a time
# Outputs ['David', 'Blessing', 'Sarah', 'Dayo', 'Bayo', 'James', 'Solomon', 'Toye']

- insert()    Adds an element at the specified position
names.insert(4, 'Joe')
# Ouputs ['David',

- pop()    Removes the element at the specified position
# Outputs 'Sarah'

- remove()    Removes the first item with the specified value
# Outputs ['David', 'Dayo', 'Joe', 'Bayo', 'James', 'Solomon', 'Toye']

- clear()    Removes all the elements from the list
# Outputs []

- reverse()    Reverses the order of the list
names = ['David', 'Blessing', 'Sarah', 'Dayo']
# Outputs ['Dayo', 'Sarah', 'Blessing', 'David']

- sort()    Sorts the list
# Outputs ['Blessing', 'David', 'Dayo', 'Sarah']

Did you find this article valuable?

Support Blessing Aliu by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
Share this