Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Basic Python Amlan Talukder.

Similar presentations


Presentation on theme: "Learning Basic Python Amlan Talukder."— Presentation transcript:

1 Learning Basic Python Amlan Talukder

2 Why Python? Easier language to code
Can get things done faster in less effort Easier language to learn Platform independent

3 How to install Python (Windows/Mac)

4 How to install Python (Linux)
sudo apt-get install python (Debian/Ubuntu) sudo yum install python (RedHat/CentOS/Fedora)

5 Useful python resources
Online tutorial Book Dive into Python

6 How to run Python Open “Command Prompt” in Windows OS or “Terminal” in Linux/MAC OS Type the following command to run a code file named “mypython.py”

7 How to run Python Open a program named “IDLE (Python GUI)”
Open your python source file “mypython.py” in IDLE Type print ‘Hello World’ in the editor Click “Run -> Run Module” to run the code

8 Python variables No need to declare the type of a variable
Any variable type can be converted into another type Variable Types: int (Any integer, ex: 0, 12, 29, 998) float (Any floating point number, ex: ) str (Any text, ex: ‘The sky is blue’ or “The quick brown fox”) bool (True or False) For single line comment, use ‘#’ and for multiline comment, use ”””

9 Python variables

10 Condition statements if <statement>: <do something>
else: <do something else> if <statement>: <do something> elif <another statement>: <do something else> else:

11 Loops in Python

12 Functions in Python

13 List List is a collection of objects (variables or other lists or dictionaries)

14 List functions A[x], get element in list A at position x
A.append(x), append x to A list A.insert(p,x), insert x to A at position p A. index(x), get the first position of x in A, error it not found A.count(x), get the occurrence of x in A A.sort(reverse=True/False), sort list A. True/False set the sorting order. A[x:y] , get the subset of list A from position x to position y.

15 String functions

16 String functions A[x], get the element at position x of A
len(A), get the length of string A A.upper(), get all uppercase of string A A.lower(), get all lowercase of string A A.split(), split string A with specific separator. .join(Asplit), join the list of strings Asplit with a separator A[x:y], the substring of A from x to y

17 List comprehension

18 File read/write

19 Basic operators and “math” library
+, -, *, /, **, +=, -=, %, and, or, =, == math.sqrt(number) math.pow(number, power) math.log(number) math.ceil(number) math.floor(number)

20 Basic operators and “math” library

21 Questions?


Download ppt "Learning Basic Python Amlan Talukder."

Similar presentations


Ads by Google