Python Basics

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22
 
1/23/23, 10:00 AM1.2localhost:8888/nbconvert/html/Desktop/DATA WRANGLING/PYTHON/1.2 python for data science introduction/1.2.ipynb?download=false1/2
 Input In [2] global = 1 ^SyntaxError: Input In [4] 21_abc12 =10 ^SyntaxError:
#Get all keywords in python 3.6
import
 keywordprint(keyword
.
kwlist)print("Total number of keywords ", len(keyword
.
kwlist))
global
 
=
 1abc12
=
 10 
#can't use special symbols as an identifier
21_abc12
=
10
 
1/23/23, 10:00 AM1.2localhost:8888/nbconvert/html/Desktop/DATA WRANGLING/PYTHON/1.2 python for data science introduction/1.2.ipynb?download=false2/2
 Input In [6] a@ = 10 ^SyntaxError:
a
=
10;b
=
20;print("the value of a is {} and b is {} "
.
format(a,b)) a
@
 
=
 10
5
 
1/23/23, 11:48 AM1_3localhost:8888/nbconvert/html/Desktop/DATA WRANGLING/PYTHON/1.2 python for data science introduction/1_3.ipynb?download=false1/3
#Print Hello, world to console
print("Hello, world 2")
#This is a long comment#and it extends #Multiple lines
"""This is also aperfect example ofmulti-line comments"""
def
 double(num):  """ function to double the number """ 
return
 2 
*
 num
5
 
1/23/23, 11:48 AM1_3localhost:8888/nbconvert/html/Desktop/DATA WRANGLING/PYTHON/1.2 python for data science introduction/1_3.ipynb?download=false2/3
print (double(10)) print (double
.
__doc__) 
#Docstring is available to us as the attribute __doc__ of t
for
 i
in
 range(10):  print (i)
if
 
True
: print ("Machine Learning")  c
=
 "AAIC"
if
 
True
: print ("Machine Learning"); c
=
 "AAIC" a
=
 1 
#single statement
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5

Reward Your Curiosity

Everything you want to read.
Anytime. Anywhere. Any device.
No Commitment. Cancel anytime.
576648e32a3d8b82ca71961b7a986505