Basic Programming for python

Mulianaraul
2 min readFeb 8, 2021

Everything’s start with a basic concept!

In using any programming language, we must learn from the most basic things. Then, what are the basic things that are important to learn in python?

  • A data type in python and also a treatment for them
  • Conditional Statements
  • While and For loop in python

Let’s start with a data type! Python has several very interesting data types to know, including integers, strings, booleans, lists, dictionaries, tuples and sets. For each data type, maybe you already know some details of their meaning and use, so in this article I only provide examples of the implementation of each data type. So, please visit my github for getting a detail and explore it!

https://github.com/rauldatascience/Data_Science/blob/master/Data%20Types%2C%20For%2C%20If-Else-Copy1.ipynb

In this article, I only focus on using data types and while or for loop in python. I remembered that there was basic concept about programming languages, linear search and binary search. So, first, what a linear search? Linear search is the simplest searching algorithm that searches for an element in a list in sequential order. We start at one end and check every element until the desired element is not found.

So, what about a binary search? is it the same? The objective of binary search same like linear search which searches for an element in a list. But, but the concept of the algorithm is slightly different. A linear search scans one element at a time, without jumping to any item. A binary search however, cut down your search to half as soon as you find middle of a sorted list.

Let’s try it!

First, try to make a numerical list with a unique value

Code : 1

Second, try this code for linear search approach

Code : 2 (Linear Search Approach)

Third, try this code for binary search approach

Code : 3 (Linear Search Approach)

Yups, if you take a look to the figure above, in using the binary search approach we have to sort our lists first.

Let’s do a backtesting of our code!

Yes, that’s all about implementation of basic programming using python!

--

--