Python — 2

Hi guys… 😍

This post will be a continuation of my previous post on Python that focused on the output statement and variables ( ). So lets get coding!


Lists are similar to arrays and can contain as many variables as necessary. In order to declare a list “fruits”:

If the elements have to be printed easily, the following piece of coding can be used:

Declare a list, add elements to it and print them

Basic Operators

The arithmetic operators in Python is pretty much the same as with other languages:
+ → addition
- → subtraction
* → multiplication
/ → division
% → remainder

If a power relation has to be created, we can use **.
e.g., 5 ** 2 → means 5 to the power 2 (squared)
6 ** 3 → means 6 to the power 3 (cubed)

In the previous post we discussed how + is used for concatenating strings. Similarly, * can be used for multiplying a string for a number of times.
e.g., zoo = “monkeys “ * 100 → This statement will type “monkeys “ for a 100 times.

Lists can also be concatenated with + sign, where what happens is that all elements in the involved lists are combined to create a new , lengthened list.

Lists can also be used for repeating a string for a number of times using * sign.
e.g., print([1, 2, 3] * 5) → This statement would repeat the given set for 5 times.

Some arithmetic operations

String Formatting

In the previous post also we discussed a few conversion specifiers. They are also known as “argument specifiers”. Here is a summary on some basic argument specifiers:

Basic String Operations

***** Please note that indexing in Python, like most languages, start from 0, which means that if we need the 4th letter, we must give the index as 3 (0, 1, 2, 3 ). *****

***** If indexing starts from the end of a string, it begins from -1. *****

The following is a summary on the operations on strings that can be done:

So guys, that’s it for this post. I hope it helped you to develop your knowledge on Python further. Please try out the tutorial and check your answers from folder Python — 2 in and do your own research too. Till I meet you on the next one, Happy Coding! 🥰

Ciao… 👋

Originally published at on November 29, 2019.




I am a Cyber Security Enthusiast who is also into movies and books! I hope to share a lot of interesting stuff!! :)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SpookySwap Development Update #7

Forget the S for SOLID, What Matters Is Delivering Your App

Black (1976) Model in Python; Predict European Option Prices on Bonds, Commodities and Futures…

Get free 3 digital assets * Maximum addresses to get free assets is 10 XLM addresses each…

How to create cool figures with Matplotlib

Integer Overflow in Java

4 Steps To Success In Web Development

Quick-start spring rest-api with Cassandra

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himashi Karunathilake

Himashi Karunathilake

I am a Cyber Security Enthusiast who is also into movies and books! I hope to share a lot of interesting stuff!! :)

More from Medium

Understanding Dictionary in Python

Installing Python-ldap on Windows

Python Loops

Generator in Python