2. Agenda
➢ What is Python
➢ Why Python
➢ Installation
➢ Basic Syntax :
• Hello World !
• Numbers
• Strings
• Loops
• Conditional Statement
• List
• Dictionaries
• Tuples
• Functions
➢ Summary
➢ Q/A
3.
4. Python
● High Level Programming Language for general
purpose programming
● Created by Guido Van Rossum
● Release in 1991
● Interpreted not Compiled
● Open Source
5. Guido Van Rossum
● Author of Python
● University of Amsterdam
-MA in Computer Science
● Google (2005 – 2012)
● Dropbox (2012-Present)
“ I was looking for a "hobby" programming project that would keep
me occupied during the week around Christmas. My office ... would
be closed, but I had a home computer, and not much else on my
hands. I decided to write an interpreter for the new scripting
language.. ”
6. Why was Python Named Python?
“ I needed a short, simple,
unique and slightly mysterious
name, so I decided to call it
Python.”
20. Talk is Cheap, Show me the Code
- Linus Torvalds
Basic Syntax
21. Hello World!
>>> print(“Hello World !”)
#include<stdio.h>
void main()
{
printf(“Hello World !”);
}
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World");
}
}
22. Numbers
>>> a = 5
>>> type(a)
<class 'int'>
>>> (-7 + 2) * (10)
-50
>>> (2 ** 4)/4
4
>>> a = 5.0
>>> type(a)
<class ‘float’>
>>> 4/0
ZeroDivisionError: division by zero
23. Strings
>>> s = ‘Hello I am learning Python.’
>>> s
‘Hello I am learning Python.’
>>> s = “This is a n Multiline String.”
>>> s
‘This is a n Multiline String.’
>>> print(s)
This is a
Multiline String.
>>> s = “”” This is another way of
declaring multiline
string.”””
>>> s
This is another way of n declaring multiline n string.
24. String Opeartions
>>> s = “your name”
>>> s.title()
‘Your Name’
>>> s.upper()
‘YOUR NAME’
>>> s.lower()
‘your name’
>>> s.swapcase()
‘YOUR NAME’
>>> s + “ is awesome.”
‘your name is awesome.’
25. Loops
>>> for i in range(1,10):
print(i)
1....9
>>> i = 1
>>> while(i<10):
print(i)
i += 1
1....9
>>> for i in range(1,10,2):
print(i)
1 3 5 7 9
26. Conditional Statement
>>> a = 1
>>> if (a==1):
print(“Number is 1”)
Elif (a==2):
print(“Number is 2”)
Elif (a==3):
print(“Number is 3”)
Else:
print(“Wrong number.”)
Number is 1
27. List
>>> list = [1,4,3,2,7,6,5]
>>> print(list)
[1, 4, 3, 2, 7, 6, 5]
>>> print(list[1])
4
>>> list[1] = list[1] + 10
>>> list
[1, 14, 3, 2, 7, 6, 5]
>>> list = list + [20,10]
[1, 14, 3, 2, 7, 6, 5, 20, 10]
>>> for i in list:
print(i)
>>> 20 in list
True
( Upgraded version of Array )