Vinay Mavi
A fullstack developer curious to explore every thing in web development domain.
@vinaymavi
Agenda
What is python
Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provides constructs that enable clear programming on both small and large scales.
Python features a dynamic type system and automatic memory management. It supports multiple programming paradigms, including object-oriented, imperative, functional and procedural, and has a large and comprehensive standard library.
How to install
How to install
Local Modules
Local Modules
print, print() | print() |
---|---|
str, unicode | str by default has unicode support |
Integer devision 3/2 = 1 3/2.0 = 1.5 |
Integer devision 3/2 = 1.5 |
REPL
hello world
# Python 2.x
print "Hello World"
print("Hello World")
#Python 3.x
print("Hello World")
Data Types
Data Types
a = 10
b = 10.0
c = 9
# Math operations
a/b = 1
c/a = 0
c/b = 0.9
Data Types
msg1 = 'Hello World'
msg2 = "Hello World"
msg3 = """Hello World"""
# Print
print msg1
print msg2
print msg2
# Formatting
print "Hell0 %s"% 'world'
print "Hello {}".format('world')
print "Hello {0} {1}".format('vinay','kumar')
# Substring
# strip,lstrip,rstrip
# dir
# help
Data Types
t = (1,2,3,4)
print t
Data Types
l = [1,"tow",3.0,('one','tow','tree')]
print t
# Operation
append
# Get values
Data Types
d = {
'msg':"Hello World",
'number':10
}
# access
#d['<key_name>']
print d['msg']
print d['number']
What is boolean
Mutable and Immutable
Hash bang
#!/usr/bin/env python
print "Hello World"
Read values
#!/usr/bin/env python
# Python2
msg = raw_input("Enter your input")
print msg
# Python3
msg = input("Enter your input")
print msg
Keywords
Conditional Statements
x = 10
if x == 0:
print "X is zero"
elif x == 10:
print "X is equal to 10"
else:
print "X = %d"% x
Conditional Statements
# if as expression.
"True" if 1 else "False"
"True" if 0 else "False"
By Vinay Mavi
Python basic and installation
A fullstack developer curious to explore every thing in web development domain.