Learning the Basics of Python for Data Science

in #python5 years ago (edited)

image.png

Basics of programming:

We use a programming language to describe what we want the computer to do. Programming languages such as Python follow grammar called syntax.

Sequential execution is when the computer performs the statements one after another in the order they are encountered in the script. Conditional execution checks for certain conditions and then execute or skip a sequence of statements. Repeat execution performs some set of statements repeatedly, usually with some variation.

Programmers are lazy and like to reuse code. When programming it is common practice to reuse as much code as possible.

History of python:

The name of the programming language Python was not named after the snake Python as some would think but rather named after Monty Python Flying Circus movie. The founder Guido van Rossum wanted to build a capable and easy to learn programming language.

Python first appeared in 1990 but has evolved since then and is continually changing as it is still under development. Python has become one of the most used programming languages. Python is a popular programming language for Data Science and machine learning.

The print function:


The print function in python is a way to provide users with feedback via the terminal. It is useful for the output of some data to the terminal.

print("Hello World")

This code gives the output Hello World to the terminal. This is the most basic example used in coding. The print function can be used to give output to the user but also has an important function as a debugging tool.

Debugging:


Debugging refers to the act of finding and removing or fixing errors within code. Hours can be spent on debugging code. Sometimes the errors can be easy to fix such as a syntax error while logic and semantic errors can be harder to fix.

Syntax error is the first errors you will make and the easiest to fix. A syntax error means that you have violated the “grammar” rules of Python.

Logic error is when your program has good syntax but there is a mistake in the order of the statements or perhaps a mistake in how the statements relate to one another.

Semantic error is when your description of the steps to take is syntactically perfect and in the right order but there is simply a mistake in the program

Comments in Python:

There are three main types of ways to make comments in python or comment out lines of code namely the hash symbol #, three double quotations “”” or three single quotations ”’. Comments are used to describe your code which can make it easier for someone else to follow and will help make it easier in the debugging stage of the coding.

image.png

Commenting out lines of code can be used when debugging code if you want a certain part of the code to not to run. This will help in the process of finding bugs if the code runs with a part of the code commented out then the bug is usually as a result of the commented out code.



Sort:  

please carry on, i want to learn more about this

This post has received a 13.82 % upvote from @boomerang.

Interesting about the history of it. I didn't know it was a reference to Monty Python. Now I have "always look on the bright side of life" stuck in my head though...

Coin Marketplace

STEEM 0.25
TRX 0.25
JST 0.039
BTC 95803.39
ETH 3334.91
USDT 1.00
SBD 3.31