Python for AI, Data Science

Types of variable
  • List is an collection of elements of different type.
  • It is mutable and allow duplicates.
  • To create list pass elements in square brackets and separate elements with comma(‘,’).
  • To access elements in list use index and index start with 0.
List function
List compression
  • It is immutable and allow duplicates.
  • It is created by storing elements in round brackets and delimited by “,”.
  • Access elements by index and index start with zero.
  • Try to change value of tuple.
tuple error
  • It is mutable and does not allow duplicate.
  • It is created by enclosing elements with curly brackets delimited by “,”.
  • It is mutable and duplicate is allowed.
  • It is created by enclosing the key-value pairs with in curly brackets delimited by “,”.
if condition:
block of code_1
block of code_2
for variable in sequence:
block of code
  • A function is a block of code that can be reused.
  • If is defined using ‘def’ keyword.
  • The syntax of function
def function_name(function_parameter):
block of code
return # optional
  • OOPs means we can solve problem by creating object.
  • Class is a blueprint for the object. It is defined with keyword class. For example iphone, oppo are object of class phone. The class phone has common attribute color, length, breath, battery.
  • Object is an entity that has attributes and behavior. It is created by assigning classname as function to an variable. Now that variable will become object of class to access class attributes and behavior. For example iphone is object who has attributes such as color, length, breadth etc.
  • Methods: are the behavior of object. Fox example iphone used to capture good picture.
class phone and object iphone_X




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

Recommended from Medium

Engineering OKR examples: How to write Objectives and Key Results

My experience in Bootcamp so far

Microservice in Healthcare part 2 — Camunda BPM

How Amazon Web Services (AWS) Is Powering Netflix ??

Clear Program .cache files on Ubuntu 20.10

Why Outsourcing Software Development is the Best Option in the US?

5 Features That You Will Love for Dot Net version 5

Using Ingress As A Load Balancer (Minikube)

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
Shoaib Rashid

Shoaib Rashid

More from Medium

List Comprehension in Python

Data Science — Basic Python

Everything you need to know about Python Lists- Part 1/2 (2022)

Python for Data Science — NumPy