SlideShare a Scribd company logo
Python - Part 1
Getting started with Python
Tradeyathra - Stock market training and forecasting experts
Nicholas I
Agenda
Introduction
Basics
Strings
Control Structures
List, Tuple, Dictionary
Functions
I/O, Exception Handling
Regular Expressions
Modules
Object Oriented Programming
Program & Programming
What is Python?
Where It’s Used?
Installation
Practice
Introduction
Module 1
A Program is a set of instructions that a computer follows to perform a particular
task.
Program
Step 1
Plug the TV wire to
the electric switch
board.
Step 2
Turn your Tv on.
Step 3
Press the power
button on your TV
remote.
Step 4
Switch between the
channels by directly
entering the numbers
from your remote.
How to turn on a tv with remote
Programming is the process of writing your ideas into a program using a computer
language to perform a task.
Programming
Programming languages
● It was created in 1991 by Guido van Rossum.
● Python is an interpreted, interactive, object-oriented programming language.
● Python is a high-level general-purpose programming language that can be
applied to many different classes of problems.
● Python is portable: it runs on many Unix variants, on the Mac, and on Windows
2000 and later
● Easy to learn and understand.
● Simple syntax and Flexible.
What is Python?
Where it is used?
Web and Internet
Development
Scientific & Numeric Games Desktop GUI
Software
Development
Business
Applications
Cloud & Data Center
IoT, Machine
Learning & AI
Installation
Windows
● https://www.python.org/ftp/python/3.6.6/python-3.6.6rc1-webinstall.exe
● Follow the wizard and finish the installation.
● Setup the environment variables.
Mac and Linux
● Mac and Linux comes with python preinstalled.
Practice
Time to set-up
python on your system...
Questions & Answers
Interactive & Script Mode
Comments
Numbers
Variables
Constants
Input and Output
Basics
Module 2
Interactive & Script Mode
Script Mode
Interactive
Comments
# Single Line Comment
# multi
# line
# Comment
""”
Docstring is short for documentation string.
It is a string that occurs as the first statement in a module, function, class, or method definition.
We must write what a function/class does in the docstring.
"""
Numbers
addition >>> 8 + 5
13
subtraction >>> 8 - 5
3
multiplication >>> 8 * 5
13
division >>> 8 / 5
13
exponent >>> 4 ** 3
64
negation >>> -2 + -4
-6
Integer and Float
int >>> 35
35
>>>float >>> 30.5
30.5
An int is a whole number A float is a decimal number
Order of Operations
>>> ( 5 + 7 ) * 3 >>> 5 + 7 * 3
36 26
PEMDAS: Parentheses Exponent Multiplication Division Addition Subtraction
>>> 12 * 3 >>> 5 + 21
Variables
>>> apples_in_box = 10
5
Variable is the container that stores some value.
>>> apples_sold = 5
>>> apples_balance = apples_in_box - apples_sold
5
10
>>> fruit_box = 100
variable name Value to be stored
Naming Variables
Name your variables meaningful and As long as you’re not breaking these rules,
you can name variables anything you want.
no spaces = 0 X No spaces in the name
3eggs, $price X No digits or special characters in front
Constants
Constants are used to store a value that can be used later in your program. The
value of the constant remains same and they do not change.
>>> PI = 3.14
constant name Value to store
>>> GRAVITY = 9.8
Input and Output
>>> input([prompt])
Function to accept
value from users
via cli
Value to be
entered by user
>>> print([output])
Function to output
value to users
Value printed on
the user screen
String Delimiters
Concatenation
Triple quoted string literals
Escape Codes
String Methods
Strings
Module 3
Strings
A string in Python is a sequence of characters. For Python to recognize a
sequence of characters, like hello, as a string, it must be enclosed in quotes to
delimit the string.
>>> "Hello"
Note:
A string can have any number of characters in it, including 0. The empty string is '' (two quote characters with nothing
between them). Many beginners forget that having no characters is legal. It can be useful.
>>> 'Hello'
Concatenation
The plus operation with strings means concatenate the strings. Python looks at
the type of operands before deciding what operation is associated with the +.
>>> "Firstname" + "lastname" >>> 'Hello'
Firstnamelastname
>>> 3 * 'Smart' + 'Phone'
SmartSmartSmartPhone
>>> 7 + "star"
?
Note:
The line structure is preserved in a multi-line string. As you can see, this also allows you to embed
both single and double quote characters!
Triple Quoted String Literals
Strings delimited by one quote character are required to be within a single line.
For example: ‘hello’.It is sometimes convenient to have a multi-line string, which
can be delimited with triple quotes, '''.
Note:
The line structure is preserved in a multi-line string. As you can see, this also allows you to embed
both single and double quote characters!
Escape Codes
Escape codes are embedded inside string literals and start with a backslash
character . They are used to embed characters that are either unprintable or
have a special syntactic meaning to Python that you want to suppress.
String Methods
Python has quite a few methods that string objects can call to perform frequency
occurring task (related to string). For example, if you want to capitalize the first
letter of a string, you can use capitalize() method
capitalize() Converts first character to capital letter
count() Counts the occurrences of a substring
upper() Returns uppercased string
lower() Returns lowercased string
len() Returns length of a string
split() Separates the words in sentences.
split()
if , elif and else
while
for
break
Control
Structures
Module 4
if, elif & else
if condition:
statements
else:
statement
if condition:
statements
elif condition:
statements
else:
statements
a = 0
if a == 0:
print('A is equal to 0')
else:
print('A is not equal to 0')
a = 2
if a == 0:
print('A is equal to 0')
elif a == 1:
print('A is equal to 1')
else:
print('A is not equal to 0 or 1')
The
if…elif…else
statement is
used for
decision
making.
Syntax Syntax
Run Run
Login
uname = 'admin'
pword = 'admin'
# user to enter their usernname & password
usernname = input('username: ')
password = input('password: ')
if usernname == uname and password == pword:
print('Login successful')
else:
print('Sorry! Invalid username and password')
while
Run the statements until a given condition is true.
while condition:
statement
Syntax
movie = 'Spider Man'
while movie == 'Spider Man':
print('Yes! I am Spider Man')
break
Run
for
Loops through elements in sequence & store in a variable
that can be used later in the program.
for variable in sequence:
statement
Syntax
for
# print 0-9 numbers using for loop
for number in range(10):
print(number)
Run
# print all the elements in fruits list
fruits = ['apple','banana','orange']
for fruit in fruits:
print(fruit)
Run
for - nested
countries = ['India','US','China','Europe']
fruits = ['apple','banana','orange']
for country in countries:
for fruit in fruits:
print(country,':', fruit)
print('-----------------')
Run
break
a = 0
while a==0:
print('hello')
Run
a = 0
while a==0:
print('hello')
break
Run
Nicholas I
Tradeyathra
nicholas.domnic.i@gmail.com
Call / Whatsapp : 8050012644
Telegram: t.me/tradeyathra
Thank You

More Related Content

What's hot (20)

Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
Edureka!
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
St. Petersburg College
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
University of Technology
 
Basics of python
Basics of pythonBasics of python
Basics of python
SurjeetSinghSurjeetS
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
Kanchilug
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to python
Mohamed Hegazy
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
Haitham El-Ghareeb
 
Programming
ProgrammingProgramming
Programming
monishagoyal4
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
Haitham El-Ghareeb
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
KrishnaMildain
 
What is Python? | Edureka
What is Python? | EdurekaWhat is Python? | Edureka
What is Python? | Edureka
Edureka!
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
Priyanka Pradhan
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
AbhishekMourya36
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
primeteacher32
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite Database
ElangovanTechNotesET
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
Edureka!
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
Kanchilug
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to python
Mohamed Hegazy
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
KrishnaMildain
 
What is Python? | Edureka
What is Python? | EdurekaWhat is Python? | Edureka
What is Python? | Edureka
Edureka!
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
Priyanka Pradhan
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Edureka!
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite Database
ElangovanTechNotesET
 

Similar to Get started python programming part 1 (20)

Python intro
Python introPython intro
Python intro
Abhinav Upadhyay
 
Python basics
Python basicsPython basics
Python basics
Hoang Nguyen
 
Python basics
Python basicsPython basics
Python basics
Luis Goldster
 
Python basics
Python basicsPython basics
Python basics
Tony Nguyen
 
Python basics
Python basicsPython basics
Python basics
Fraboni Ec
 
Python basics
Python basicsPython basics
Python basics
Harry Potter
 
Python basics
Python basicsPython basics
Python basics
Young Alista
 
Python basics
Python basicsPython basics
Python basics
James Wong
 
Python ppt
Python pptPython ppt
Python ppt
Anush verma
 
python_strings.pdf
python_strings.pdfpython_strings.pdf
python_strings.pdf
rajendraprasadbabub1
 
Python Strings and strings types with Examples
Python Strings and strings types with ExamplesPython Strings and strings types with Examples
Python Strings and strings types with Examples
Prof. Kartiki Deshmukh
 
An Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewAn Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm Review
Blue Elephant Consulting
 
Notes1
Notes1Notes1
Notes1
hccit
 
UNIT 4 python.pptx
UNIT 4 python.pptxUNIT 4 python.pptx
UNIT 4 python.pptx
TKSanthoshRao
 
Python
PythonPython
Python
MeHak Gulati
 
ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1
UCLA Association of Computing Machinery
 
Introduction to Python Programming .pptx
Introduction to  Python Programming .pptxIntroduction to  Python Programming .pptx
Introduction to Python Programming .pptx
NaynaSagarDahatonde
 
#Code2Create: Python Basics
#Code2Create: Python Basics#Code2Create: Python Basics
#Code2Create: Python Basics
GDGKuwaitGoogleDevel
 
Python
PythonPython
Python
Gagandeep Nanda
 
Chapter1 python introduction syntax general
Chapter1 python introduction syntax generalChapter1 python introduction syntax general
Chapter1 python introduction syntax general
ssuser77162c
 
Ad

Recently uploaded (20)

BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Rose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdfRose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdf
kushallamichhame
 
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
TV Shows and web-series quiz | QUIZ CLUB OF PSGCAS | 13TH MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Rose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdfRose Cultivation Practices by Kushal Lamichhane.pdf
Rose Cultivation Practices by Kushal Lamichhane.pdf
kushallamichhame
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdfUnit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti MpdBasic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Ad

Get started python programming part 1

  • 1. Python - Part 1 Getting started with Python Tradeyathra - Stock market training and forecasting experts Nicholas I
  • 2. Agenda Introduction Basics Strings Control Structures List, Tuple, Dictionary Functions I/O, Exception Handling Regular Expressions Modules Object Oriented Programming
  • 3. Program & Programming What is Python? Where It’s Used? Installation Practice Introduction Module 1
  • 4. A Program is a set of instructions that a computer follows to perform a particular task. Program Step 1 Plug the TV wire to the electric switch board. Step 2 Turn your Tv on. Step 3 Press the power button on your TV remote. Step 4 Switch between the channels by directly entering the numbers from your remote. How to turn on a tv with remote
  • 5. Programming is the process of writing your ideas into a program using a computer language to perform a task. Programming Programming languages
  • 6. ● It was created in 1991 by Guido van Rossum. ● Python is an interpreted, interactive, object-oriented programming language. ● Python is a high-level general-purpose programming language that can be applied to many different classes of problems. ● Python is portable: it runs on many Unix variants, on the Mac, and on Windows 2000 and later ● Easy to learn and understand. ● Simple syntax and Flexible. What is Python?
  • 7. Where it is used? Web and Internet Development Scientific & Numeric Games Desktop GUI Software Development Business Applications Cloud & Data Center IoT, Machine Learning & AI
  • 8. Installation Windows ● https://www.python.org/ftp/python/3.6.6/python-3.6.6rc1-webinstall.exe ● Follow the wizard and finish the installation. ● Setup the environment variables. Mac and Linux ● Mac and Linux comes with python preinstalled.
  • 9. Practice Time to set-up python on your system...
  • 11. Interactive & Script Mode Comments Numbers Variables Constants Input and Output Basics Module 2
  • 12. Interactive & Script Mode Script Mode Interactive
  • 13. Comments # Single Line Comment # multi # line # Comment ""” Docstring is short for documentation string. It is a string that occurs as the first statement in a module, function, class, or method definition. We must write what a function/class does in the docstring. """
  • 14. Numbers addition >>> 8 + 5 13 subtraction >>> 8 - 5 3 multiplication >>> 8 * 5 13 division >>> 8 / 5 13 exponent >>> 4 ** 3 64 negation >>> -2 + -4 -6
  • 15. Integer and Float int >>> 35 35 >>>float >>> 30.5 30.5 An int is a whole number A float is a decimal number
  • 16. Order of Operations >>> ( 5 + 7 ) * 3 >>> 5 + 7 * 3 36 26 PEMDAS: Parentheses Exponent Multiplication Division Addition Subtraction >>> 12 * 3 >>> 5 + 21
  • 17. Variables >>> apples_in_box = 10 5 Variable is the container that stores some value. >>> apples_sold = 5 >>> apples_balance = apples_in_box - apples_sold 5 10 >>> fruit_box = 100 variable name Value to be stored
  • 18. Naming Variables Name your variables meaningful and As long as you’re not breaking these rules, you can name variables anything you want. no spaces = 0 X No spaces in the name 3eggs, $price X No digits or special characters in front
  • 19. Constants Constants are used to store a value that can be used later in your program. The value of the constant remains same and they do not change. >>> PI = 3.14 constant name Value to store >>> GRAVITY = 9.8
  • 20. Input and Output >>> input([prompt]) Function to accept value from users via cli Value to be entered by user >>> print([output]) Function to output value to users Value printed on the user screen
  • 21. String Delimiters Concatenation Triple quoted string literals Escape Codes String Methods Strings Module 3
  • 22. Strings A string in Python is a sequence of characters. For Python to recognize a sequence of characters, like hello, as a string, it must be enclosed in quotes to delimit the string. >>> "Hello" Note: A string can have any number of characters in it, including 0. The empty string is '' (two quote characters with nothing between them). Many beginners forget that having no characters is legal. It can be useful. >>> 'Hello'
  • 23. Concatenation The plus operation with strings means concatenate the strings. Python looks at the type of operands before deciding what operation is associated with the +. >>> "Firstname" + "lastname" >>> 'Hello' Firstnamelastname >>> 3 * 'Smart' + 'Phone' SmartSmartSmartPhone >>> 7 + "star" ?
  • 24. Note: The line structure is preserved in a multi-line string. As you can see, this also allows you to embed both single and double quote characters! Triple Quoted String Literals Strings delimited by one quote character are required to be within a single line. For example: ‘hello’.It is sometimes convenient to have a multi-line string, which can be delimited with triple quotes, '''.
  • 25. Note: The line structure is preserved in a multi-line string. As you can see, this also allows you to embed both single and double quote characters! Escape Codes Escape codes are embedded inside string literals and start with a backslash character . They are used to embed characters that are either unprintable or have a special syntactic meaning to Python that you want to suppress.
  • 26. String Methods Python has quite a few methods that string objects can call to perform frequency occurring task (related to string). For example, if you want to capitalize the first letter of a string, you can use capitalize() method capitalize() Converts first character to capital letter count() Counts the occurrences of a substring upper() Returns uppercased string lower() Returns lowercased string len() Returns length of a string split() Separates the words in sentences.
  • 28. if , elif and else while for break Control Structures Module 4
  • 29. if, elif & else if condition: statements else: statement if condition: statements elif condition: statements else: statements a = 0 if a == 0: print('A is equal to 0') else: print('A is not equal to 0') a = 2 if a == 0: print('A is equal to 0') elif a == 1: print('A is equal to 1') else: print('A is not equal to 0 or 1') The if…elif…else statement is used for decision making. Syntax Syntax Run Run
  • 30. Login uname = 'admin' pword = 'admin' # user to enter their usernname & password usernname = input('username: ') password = input('password: ') if usernname == uname and password == pword: print('Login successful') else: print('Sorry! Invalid username and password')
  • 31. while Run the statements until a given condition is true. while condition: statement Syntax movie = 'Spider Man' while movie == 'Spider Man': print('Yes! I am Spider Man') break Run
  • 32. for Loops through elements in sequence & store in a variable that can be used later in the program. for variable in sequence: statement Syntax
  • 33. for # print 0-9 numbers using for loop for number in range(10): print(number) Run # print all the elements in fruits list fruits = ['apple','banana','orange'] for fruit in fruits: print(fruit) Run
  • 34. for - nested countries = ['India','US','China','Europe'] fruits = ['apple','banana','orange'] for country in countries: for fruit in fruits: print(country,':', fruit) print('-----------------') Run
  • 35. break a = 0 while a==0: print('hello') Run a = 0 while a==0: print('hello') break Run
  • 36. Nicholas I Tradeyathra [email protected] Call / Whatsapp : 8050012644 Telegram: t.me/tradeyathra Thank You