Are you finding difficult in remembering all the syntax that you need to work with Python for Data Science?
Guys, don’t worry if you are a beginner and have no idea about how Python works, this Python for Data Science cheat sheet will give you a quick reference of the basics that you must know to get started.
While at Intellipaat, we support our learners with a handy reference, that the reason we have created this Cheat sheet. Take a deep dive to learn Python by our online tutorial.
This cheat sheet is designed for the one who has already started learning about the Python but needs a handy reference sheet.
Python is a high-level dynamic programming language which is very easy to learn. It comes with powerful typing and the codes are written in very ‘natural’ style, thats the reason, it is easy to read and understand. Python programming language can run on any platform, from Windows to Linux to Macintosh, Solaris etc.
Rule #1: Python is white-space dependent; code blocks are indented using spaces. Rule #2: Python language is case sensitive. It matters for variables, functions and any keyword in general.
In Python, every value has a datatype. in Python programming, everything is an object, data types are classes and variables are instance that means object of these classes.
There are various data types in Python. Some of the important types are listed below.
In python, Operators are only the constructs which can manipulate the value of operands. For example, in the expression 5 + 10 = 15. Here, 5 and 10 are operands and + is operator.
Python provides some of the built-in operations on various data types.
Python programming language provides various looping and control statement that allow for more complicated execution paths.A loop statement allows us to execute a statement or group of statements multiple times.
if price>=700: print(“Buy.”) else: print(“Don’t buy.”)
a=“New Text” count=0 for i in a: if i==‘e’: count=count+1 print(count)
a=0 i=1 while i<10: a=a*2 i=i+1 print(a)
Watch this Python Tutorial video
A function is a block of code which only runs when it is called. We can pass data (parameters) into a function and after executing a function, it will return data as a result.
def new_function(): print(“Hello World”) new_function()
A lambda function is a small anonymous function. It can take any number of arguments but can only have one expression.
lambda a,b: a+b lambda a,b: a*b
In python, we have a huge a list of Python built-in functions. Some of them are:
In python, we have several functions for creating, reading, updating, and deleting files. Theopen() function takes two parameters – filename, and mode.
There are four different methods (modes) for opening a file:
(Opening modes: r: read, w: write, a: append, r+: both read and write)
The try block allow us to test a block of code for errors.The except block allow us to handle the error.
try: [Statement body block] raise Exception() except Exception as e: [Error processing block]
Python is an object-oriented programming language. In Python, almost everything is an object and has its own properties and methods. Here a class is like an object constructor, or a “blueprint” for creating objects.
Class: class Pen: pass object:obj=Pen()
Single line Comments in Python start with the hash character, # and multiline comment should be used with “””triple quotes”””
# Single Line Comment """ Multi-line comment """
With this, we come to an end of Python Basics Cheat Sheet. To get in-depth knowledge, check out our interactive, live-online Intellipaat Python Data Science Certification Training here, that comes with 24*7 support to guide you throughout your learning period. Intellipaat’s Python course will let you master the concepts of widely-used and powerful programming language Python. You will gain hands-on experience in working with the various Python packages like SciPy, NumPy, MatPlotLib, Lambda function and more. You will work on hands-on projects in the domain of python and apply it for various domains of big data, data science and machine learning.
A lot of questions can be raised to beginners on this topic in interview. Check out the list of Python interview questions created by the experts.Previous Next
Download Interview Questions asked by top MNCs in 2019?