Introduction to python for data engineering
Amoskinuthia
Posted on April 24, 2022
Do you want to build a website? an application? a video game
name it or manipulate data, python got you covered. Python is a multi-purpose high level programming language that can help you develop or do almost anything.
It is easily available for free and open source , it has gained popularity and it is being used by big organizations like Google, Disney and even NASA.
Python has evolved and now we have python 3 which is the latest version. Python is famous among data handlers that is data engineers, data scientists and data analysts, this because it has a wide variety of libraries and modules like Pandas, numpy, scikit-learn,seaborn, matplotlib etc that make data preparation,data processing and data analysis efficient. data engineers use python to create data pipelines and to write script to automate data cleaning amongst other processes
lets try it!
lets try writing our 1st python program and see how simple it is
print(`hello world!`)
output: hello world!
The print statement will be followed by a parentheses that enclose what we want displayed as our output
python syntax
whitespaces and indentation
Python uses whitespace and indentation to construct the code structure unlike other programming languages that use semicolons to separate statements.
comments
Comments help us document our code for future reference
we have several ways of writing comments in python
- using #
`#this is a comment`
it is mostly used for single line comments
- using ***
`*** this is a multiline comment***`
identifiers
Identifiers are used to identify variables, functions and other objects in python.
The name of an identifier should begin with a letter or an _
python is case sensitive and therefore care should be taken when naming them.
it is important to note that python key words should not be used as identifiers
keywords
Some keywords in python are listed below
False
class
None
True
while
raise
this are words which have a special meaning in python
you can use the code below to list all the keywords
import keyword
print(keyword.kwlist)
Data types
strings
integers
floats
*control flow *
Boolean and comparisons
Booleans have two values that is true and false
if statements
with if statements the condition check and if its true the statement is executed otherwise they are not.
x=45
if x>5:
print ("x is greater than 5")
else statements
The else statement can be used to execute statements if the if statements is false.
Same as if statements the code inside the statement needs to be indented.
x=4
if x==5:
print("yes")
else:
print("no")
while loops
we use while loops to repeat a block of code several times
i=1
while i<=5:
print(i)
i=i+1
print("finished!")
_break _
This is used to break a while loop if the conditions we want are matched
`i=0
while true:
print(i)
i=i+1
if i>=5:
print("breaking")
break`
Posted on April 24, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024