SlideShare une entreprise Scribd logo
1  sur  22
PYTHON OVERVIEW
Why Python?
 Simple
 Powerful
 Usually preinstalled
 Less Syntax
 Open Source
 Plethora of PenTestTools already created
Interpreted?
• Python is interpreted, which means that python code is translated
and executed by an interpreter one statement at a time.
• This means you can run commands/code on the command
prompt…
• Through a command
prompt with a text file…
• Using an IDE
What Does It Look Like?
Good programming proclamations
 Using comments to denote programs or sections of code
◦ A comment beginning with # is called a single-line comment because it
terminates at the end of the current line.
◦ You also may use a multi-line comment—possibly containing many
lines—begins with ’’’ and ends with ’’’.
 You use blank lines, space characters and tab characters (i.e., “tabs”)
to make programs easier to read.
◦ Together, these characters are known as white space.
◦ White-space characters are USUALLY ignored by the interpreter.
◦ Python has its own rules with white space
Printing a Line of Text
• Code: print(“ “) Python 3
• Code: print “ “ Python 2
• Anything placed inside the quotes will be printed on the screen upon execution
of the print command.
Output
Obtaining input
 How to input values from the user
› Code: variable = input(“Prompt “) Python 3
› Code: variable = raw_input(“Prompt”) Python 2
› variable – stores the input from the user.
› input – function to extract user input from the command prompt.
› “Prompt” – a string to inform the user of the type of value to enter.
 Ex. Inputting a numerical value
testGrade1 = input(”Enter test grade 1: “)
testGrade *= 100
print(”Test Grade: “, testGrade, “%”)
Good Programming:Organize outputs, good prompts
DataType Conversion
• Can control how variables are interpreted within the
program:
• Evaluation
• Code: eval(string)
• Ex. eval(“51” + “52”)
• eval( str1 ** str2)
• test = eval(input(“Enter a num”))
Conditional Operators
• Operator Meaning
• == equal to
• < less than
• <= less than or equals to
• > greater than
• >= greater than or equal to
• != not equal to
• Common Mistake:Confusing = with ==
Decision Structures
• Code:
Creating a decision structure:
if (expression):
statement
• To execute more than one statement in a block they must be indented equally:
if (score > 90):
grade = 'A'
print(“Good Job!n”)
print(“Not part of the conditions execution”)
• Good Programming: Commenting conditional blocks
• Common Mistakes: Forgetting equal indent, forgetting :, and forgetting space after if
• Good Practices: Use a tab not a space (harder to line up and troubleshoot)
Space Indent
Nested Conditionals
if (condition):
Statement
elif (condition):
Statement
elif (condition):
Statement
Statement
else:
Statement
• Common Errors: Not Lining up Else with its preceding If.
• Question:Why is a trailing else good programming?
Nested if/else if Example
Question: What zodiac sign is it for the current year?
Logical Operators
Code:
• Using logical operators:
• if (condition or condition)
Statement
• if (condition and condition)
Statement
While Loops
• AWhile Loop is a loop that executes 0 or more times before
terminating.
• Pre-conditional loop
 Code:
 Creating aWhile Loop:
 while (condition statement):
statement1
statement2
 DebuggingTechniques:
 Setup a counter to keep track of the number of times a loop runs
 Set up a counter to count if an event is occurring or the number of
times it occurs
 Output values each time a loop executes
Example
num = eval(input(“Enter a number less than 10:”))
while (num >= 10):
print(“Invalid Entry!”)
num = eval(input(“Enter a number less than 10:”))
For Loops
• For loops are a pre-test loop
• In order to utilize a for loop you need 3 things:
1. Needs to initialize a counter
2. Must test the counter variable (less than)
3. It must update the counter variable
• Code:
for initialization in range(start, stop, increment):
statement1
statement2
Example
for i in range(0, 5, 1):
print(“Hello”)
Step 1: Perform the initialization
expression
Step 2: Evaluate the test expressions
Step 3: Execute the body of the
loop
Step 4: Perform the
update
Assign 0 to i
i < 5
Update iPrint “Hello”
True
False
Function Definition
• Definition includes:
• return value: the value the function returns to the part of the
program that called it
• name: name of the function. Function names follow same rules
as variables
• parameter list: variables containing
values passed to the function
• body: statements that perform
the function’s task
Calling a Function
• Functions just like variables need to be called in order
to be invoked
• Code:
Calling a Function:
 functionName (Parameters)
Write and Calling Functions Example
Modules
• Some special functions have not been innately included into the interpreter to
speed up the loading process, these packages are known as modules.
• Code: import moduleName
• Ex.
• import math
• import random
• Import os
• OS module
• os.getcwd()
• os.chdir(path)

Contenu connexe

Tendances

Presentation on python
Presentation on pythonPresentation on python
Presentation on pythonwilliam john
 
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
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019Samir Mohanty
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaEdureka!
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming pptismailmrribi
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in PythonSumit Satam
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Edureka!
 
Python Basics
Python BasicsPython Basics
Python BasicsPooja B S
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialQA TrainingHub
 

Tendances (20)

Presentation on python
Presentation on pythonPresentation on python
Presentation on python
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | Edureka
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Python
PythonPython
Python
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...Python Programming Language | Python Classes | Python Tutorial | Python Train...
Python Programming Language | Python Classes | Python Tutorial | Python Train...
 
Python basic
Python basicPython basic
Python basic
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Python
PythonPython
Python
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
 

En vedette

Processing Regex Python
Processing Regex PythonProcessing Regex Python
Processing Regex Pythonprimeteacher32
 
Reading and Writing Files
Reading and Writing FilesReading and Writing Files
Reading and Writing Filesprimeteacher32
 
More Pattern Matching With RegEx
More Pattern Matching With RegExMore Pattern Matching With RegEx
More Pattern Matching With RegExprimeteacher32
 
Processing with Regular Expressions
Processing with Regular ExpressionsProcessing with Regular Expressions
Processing with Regular Expressionsprimeteacher32
 
Matching with Regular Expressions
Matching with Regular ExpressionsMatching with Regular Expressions
Matching with Regular Expressionsprimeteacher32
 
Basic .Net Training in Hyderabad
Basic .Net Training in HyderabadBasic .Net Training in Hyderabad
Basic .Net Training in HyderabadUgs8008
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No RegretsAlex Ezell
 
Python Programming - II. The Basics
Python Programming - II. The BasicsPython Programming - II. The Basics
Python Programming - II. The BasicsRanel Padon
 
Introduction To Unix
Introduction To UnixIntroduction To Unix
Introduction To UnixCTIN
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For ManagersAtul Shridhar
 

En vedette (20)

Processing Regex Python
Processing Regex PythonProcessing Regex Python
Processing Regex Python
 
Reading and Writing Files
Reading and Writing FilesReading and Writing Files
Reading and Writing Files
 
CSV File Manipulation
CSV File ManipulationCSV File Manipulation
CSV File Manipulation
 
Json
JsonJson
Json
 
Sending Email
Sending EmailSending Email
Sending Email
 
Web Scraping
Web ScrapingWeb Scraping
Web Scraping
 
More Perl Basics
More Perl BasicsMore Perl Basics
More Perl Basics
 
More Pattern Matching With RegEx
More Pattern Matching With RegExMore Pattern Matching With RegEx
More Pattern Matching With RegEx
 
File I/O
File I/OFile I/O
File I/O
 
Processing with Regular Expressions
Processing with Regular ExpressionsProcessing with Regular Expressions
Processing with Regular Expressions
 
Matching with Regular Expressions
Matching with Regular ExpressionsMatching with Regular Expressions
Matching with Regular Expressions
 
Passing Arguments
Passing ArgumentsPassing Arguments
Passing Arguments
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Subroutines
SubroutinesSubroutines
Subroutines
 
Basic .Net Training in Hyderabad
Basic .Net Training in HyderabadBasic .Net Training in Hyderabad
Basic .Net Training in Hyderabad
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
 
presentation on Unix basic by prince kumar kushwhaha
presentation on Unix basic by prince kumar kushwhahapresentation on Unix basic by prince kumar kushwhaha
presentation on Unix basic by prince kumar kushwhaha
 
Python Programming - II. The Basics
Python Programming - II. The BasicsPython Programming - II. The Basics
Python Programming - II. The Basics
 
Introduction To Unix
Introduction To UnixIntroduction To Unix
Introduction To Unix
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 

Similaire à Python Overview: Simple, Powerful & Interpreted Programming Language

Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chhom Karath
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Amr Alaa El Deen
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha BaliAkanksha Bali
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdflailoesakhan
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & LoopsAkhil Kaushik
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introductionstn_tkiller
 
Introduction To Python.pptx
Introduction To Python.pptxIntroduction To Python.pptx
Introduction To Python.pptxAnum Zehra
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxansariparveen06
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statementsVladislav Hadzhiyski
 

Similaire à Python Overview: Simple, Powerful & Interpreted Programming Language (20)

Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
 
Python ppt
Python pptPython ppt
Python ppt
 
Python basics
Python basicsPython basics
Python basics
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
 
Python basics
Python basicsPython basics
Python basics
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
 
Review Python
Review PythonReview Python
Review Python
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
 
85ec7 session2 c++
85ec7 session2 c++85ec7 session2 c++
85ec7 session2 c++
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
Python
PythonPython
Python
 
Module-1.pptx
Module-1.pptxModule-1.pptx
Module-1.pptx
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introduction
 
Introduction To Python.pptx
Introduction To Python.pptxIntroduction To Python.pptx
Introduction To Python.pptx
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statements
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 

Plus de primeteacher32

Plus de primeteacher32 (20)

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Returning Data
Returning DataReturning Data
Returning Data
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
 
Introduction to GUIs with guizero
Introduction to GUIs with guizeroIntroduction to GUIs with guizero
Introduction to GUIs with guizero
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
 
Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
 
Conditionals
ConditionalsConditionals
Conditionals
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
 
Block chain security
Block chain securityBlock chain security
Block chain security
 

Dernier

Thomas Calculus 12th Edition Textbook and helping material
Thomas Calculus 12th Edition Textbook and helping materialThomas Calculus 12th Edition Textbook and helping material
Thomas Calculus 12th Edition Textbook and helping materialsafdarhussainbhutta4
 
Design, Desire and Demand Presentation.pptx
Design, Desire and Demand Presentation.pptxDesign, Desire and Demand Presentation.pptx
Design, Desire and Demand Presentation.pptxaaronbasko1
 
The Next Things To Immediately Do About Mating Press
The Next Things To Immediately Do About Mating PressThe Next Things To Immediately Do About Mating Press
The Next Things To Immediately Do About Mating Pressmatingpress170
 
Jumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3AJumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3Ajumarkdiezmo1
 
Back on Track: Navigating the Return to Work after Parental Leave
Back on Track: Navigating the Return to Work after Parental LeaveBack on Track: Navigating the Return to Work after Parental Leave
Back on Track: Navigating the Return to Work after Parental LeaveMarharyta Nedzelska
 
LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024Bruce Bennett
 
Soviet pilot Yuri Gagarin was the first person to ever orbit the Earth
Soviet pilot Yuri Gagarin was the first person to ever orbit the EarthSoviet pilot Yuri Gagarin was the first person to ever orbit the Earth
Soviet pilot Yuri Gagarin was the first person to ever orbit the EarthChristina Parmionova
 
LinkedIn for Your Job Search in April 2024
LinkedIn for Your Job Search in April 2024LinkedIn for Your Job Search in April 2024
LinkedIn for Your Job Search in April 2024Bruce Bennett
 
401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx
401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx
401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptxwaghmare9860lavin
 
Complete Benefits of career counseling in India
Complete Benefits of career counseling in IndiaComplete Benefits of career counseling in India
Complete Benefits of career counseling in IndiaMere Mentor
 
Chapter 4 - Promoting Inclusive Culture.ppt
Chapter 4 - Promoting   Inclusive Culture.pptChapter 4 - Promoting   Inclusive Culture.ppt
Chapter 4 - Promoting Inclusive Culture.pptmoytopo
 
Get to know about Raquel Thompson Barbados.pdf
Get to know about Raquel Thompson Barbados.pdfGet to know about Raquel Thompson Barbados.pdf
Get to know about Raquel Thompson Barbados.pdfRaquel Thompson Barbados
 
How to prepare yourself for a job interview.pptx
How to prepare yourself for a job interview.pptxHow to prepare yourself for a job interview.pptx
How to prepare yourself for a job interview.pptxJohnreyFalsarioBasid
 
Banged Dubai Call Girls O525547819 Call Girls Dubai
Banged Dubai Call Girls O525547819 Call Girls DubaiBanged Dubai Call Girls O525547819 Call Girls Dubai
Banged Dubai Call Girls O525547819 Call Girls Dubaikojalkojal131
 
APSC Motor Vechile Inspector 18 Posts.pdf
APSC Motor Vechile Inspector 18 Posts.pdfAPSC Motor Vechile Inspector 18 Posts.pdf
APSC Motor Vechile Inspector 18 Posts.pdfsoumita869
 
Network to Success - Using Social Media in Job Search
Network to Success - Using Social Media in Job SearchNetwork to Success - Using Social Media in Job Search
Network to Success - Using Social Media in Job SearchBruce Bennett
 
What is the career path of a VFX artist?
What is the career path of a VFX artist?What is the career path of a VFX artist?
What is the career path of a VFX artist?santoshjadhav126
 
Transportation and Trade Part 5 (1) (1).pptx
Transportation and Trade Part 5 (1) (1).pptxTransportation and Trade Part 5 (1) (1).pptx
Transportation and Trade Part 5 (1) (1).pptxSheldon Byron
 
加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作
加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作
加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作rpb5qxou
 
Abanoub Ghobrial, Planning Team Leader.pdf
Abanoub Ghobrial, Planning Team Leader.pdfAbanoub Ghobrial, Planning Team Leader.pdf
Abanoub Ghobrial, Planning Team Leader.pdfAbanoubGhobrial1
 

Dernier (20)

Thomas Calculus 12th Edition Textbook and helping material
Thomas Calculus 12th Edition Textbook and helping materialThomas Calculus 12th Edition Textbook and helping material
Thomas Calculus 12th Edition Textbook and helping material
 
Design, Desire and Demand Presentation.pptx
Design, Desire and Demand Presentation.pptxDesign, Desire and Demand Presentation.pptx
Design, Desire and Demand Presentation.pptx
 
The Next Things To Immediately Do About Mating Press
The Next Things To Immediately Do About Mating PressThe Next Things To Immediately Do About Mating Press
The Next Things To Immediately Do About Mating Press
 
Jumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3AJumark Morit Diezmo- Career portfolio- BPED 3A
Jumark Morit Diezmo- Career portfolio- BPED 3A
 
Back on Track: Navigating the Return to Work after Parental Leave
Back on Track: Navigating the Return to Work after Parental LeaveBack on Track: Navigating the Return to Work after Parental Leave
Back on Track: Navigating the Return to Work after Parental Leave
 
LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024LinkedIn Strategic Guidelines April 2024
LinkedIn Strategic Guidelines April 2024
 
Soviet pilot Yuri Gagarin was the first person to ever orbit the Earth
Soviet pilot Yuri Gagarin was the first person to ever orbit the EarthSoviet pilot Yuri Gagarin was the first person to ever orbit the Earth
Soviet pilot Yuri Gagarin was the first person to ever orbit the Earth
 
LinkedIn for Your Job Search in April 2024
LinkedIn for Your Job Search in April 2024LinkedIn for Your Job Search in April 2024
LinkedIn for Your Job Search in April 2024
 
401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx
401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx
401799841-Increasing-Crimes-and-Suicides-Among-Youth.pptx
 
Complete Benefits of career counseling in India
Complete Benefits of career counseling in IndiaComplete Benefits of career counseling in India
Complete Benefits of career counseling in India
 
Chapter 4 - Promoting Inclusive Culture.ppt
Chapter 4 - Promoting   Inclusive Culture.pptChapter 4 - Promoting   Inclusive Culture.ppt
Chapter 4 - Promoting Inclusive Culture.ppt
 
Get to know about Raquel Thompson Barbados.pdf
Get to know about Raquel Thompson Barbados.pdfGet to know about Raquel Thompson Barbados.pdf
Get to know about Raquel Thompson Barbados.pdf
 
How to prepare yourself for a job interview.pptx
How to prepare yourself for a job interview.pptxHow to prepare yourself for a job interview.pptx
How to prepare yourself for a job interview.pptx
 
Banged Dubai Call Girls O525547819 Call Girls Dubai
Banged Dubai Call Girls O525547819 Call Girls DubaiBanged Dubai Call Girls O525547819 Call Girls Dubai
Banged Dubai Call Girls O525547819 Call Girls Dubai
 
APSC Motor Vechile Inspector 18 Posts.pdf
APSC Motor Vechile Inspector 18 Posts.pdfAPSC Motor Vechile Inspector 18 Posts.pdf
APSC Motor Vechile Inspector 18 Posts.pdf
 
Network to Success - Using Social Media in Job Search
Network to Success - Using Social Media in Job SearchNetwork to Success - Using Social Media in Job Search
Network to Success - Using Social Media in Job Search
 
What is the career path of a VFX artist?
What is the career path of a VFX artist?What is the career path of a VFX artist?
What is the career path of a VFX artist?
 
Transportation and Trade Part 5 (1) (1).pptx
Transportation and Trade Part 5 (1) (1).pptxTransportation and Trade Part 5 (1) (1).pptx
Transportation and Trade Part 5 (1) (1).pptx
 
加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作
加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作
加拿大MUN学位证,纽芬兰纪念大学毕业证书1:1制作
 
Abanoub Ghobrial, Planning Team Leader.pdf
Abanoub Ghobrial, Planning Team Leader.pdfAbanoub Ghobrial, Planning Team Leader.pdf
Abanoub Ghobrial, Planning Team Leader.pdf
 

Python Overview: Simple, Powerful & Interpreted Programming Language

  • 2. Why Python?  Simple  Powerful  Usually preinstalled  Less Syntax  Open Source  Plethora of PenTestTools already created
  • 3. Interpreted? • Python is interpreted, which means that python code is translated and executed by an interpreter one statement at a time. • This means you can run commands/code on the command prompt… • Through a command prompt with a text file… • Using an IDE
  • 4. What Does It Look Like?
  • 5. Good programming proclamations  Using comments to denote programs or sections of code ◦ A comment beginning with # is called a single-line comment because it terminates at the end of the current line. ◦ You also may use a multi-line comment—possibly containing many lines—begins with ’’’ and ends with ’’’.  You use blank lines, space characters and tab characters (i.e., “tabs”) to make programs easier to read. ◦ Together, these characters are known as white space. ◦ White-space characters are USUALLY ignored by the interpreter. ◦ Python has its own rules with white space
  • 6. Printing a Line of Text • Code: print(“ “) Python 3 • Code: print “ “ Python 2 • Anything placed inside the quotes will be printed on the screen upon execution of the print command.
  • 8. Obtaining input  How to input values from the user › Code: variable = input(“Prompt “) Python 3 › Code: variable = raw_input(“Prompt”) Python 2 › variable – stores the input from the user. › input – function to extract user input from the command prompt. › “Prompt” – a string to inform the user of the type of value to enter.  Ex. Inputting a numerical value testGrade1 = input(”Enter test grade 1: “) testGrade *= 100 print(”Test Grade: “, testGrade, “%”) Good Programming:Organize outputs, good prompts
  • 9. DataType Conversion • Can control how variables are interpreted within the program: • Evaluation • Code: eval(string) • Ex. eval(“51” + “52”) • eval( str1 ** str2) • test = eval(input(“Enter a num”))
  • 10. Conditional Operators • Operator Meaning • == equal to • < less than • <= less than or equals to • > greater than • >= greater than or equal to • != not equal to • Common Mistake:Confusing = with ==
  • 11. Decision Structures • Code: Creating a decision structure: if (expression): statement • To execute more than one statement in a block they must be indented equally: if (score > 90): grade = 'A' print(“Good Job!n”) print(“Not part of the conditions execution”) • Good Programming: Commenting conditional blocks • Common Mistakes: Forgetting equal indent, forgetting :, and forgetting space after if • Good Practices: Use a tab not a space (harder to line up and troubleshoot) Space Indent
  • 12. Nested Conditionals if (condition): Statement elif (condition): Statement elif (condition): Statement Statement else: Statement • Common Errors: Not Lining up Else with its preceding If. • Question:Why is a trailing else good programming?
  • 13. Nested if/else if Example Question: What zodiac sign is it for the current year?
  • 14. Logical Operators Code: • Using logical operators: • if (condition or condition) Statement • if (condition and condition) Statement
  • 15. While Loops • AWhile Loop is a loop that executes 0 or more times before terminating. • Pre-conditional loop  Code:  Creating aWhile Loop:  while (condition statement): statement1 statement2  DebuggingTechniques:  Setup a counter to keep track of the number of times a loop runs  Set up a counter to count if an event is occurring or the number of times it occurs  Output values each time a loop executes
  • 16. Example num = eval(input(“Enter a number less than 10:”)) while (num >= 10): print(“Invalid Entry!”) num = eval(input(“Enter a number less than 10:”))
  • 17. For Loops • For loops are a pre-test loop • In order to utilize a for loop you need 3 things: 1. Needs to initialize a counter 2. Must test the counter variable (less than) 3. It must update the counter variable • Code: for initialization in range(start, stop, increment): statement1 statement2
  • 18. Example for i in range(0, 5, 1): print(“Hello”) Step 1: Perform the initialization expression Step 2: Evaluate the test expressions Step 3: Execute the body of the loop Step 4: Perform the update Assign 0 to i i < 5 Update iPrint “Hello” True False
  • 19. Function Definition • Definition includes: • return value: the value the function returns to the part of the program that called it • name: name of the function. Function names follow same rules as variables • parameter list: variables containing values passed to the function • body: statements that perform the function’s task
  • 20. Calling a Function • Functions just like variables need to be called in order to be invoked • Code: Calling a Function:  functionName (Parameters)
  • 21. Write and Calling Functions Example
  • 22. Modules • Some special functions have not been innately included into the interpreter to speed up the loading process, these packages are known as modules. • Code: import moduleName • Ex. • import math • import random • Import os • OS module • os.getcwd() • os.chdir(path)

Notes de l'éditeur

  1. Read Introduction from Violent Python pg.1 -2 Perl is complex and has too many idiosyncrasies even though many prebuilt tools are designed in perl so modification is huge Java and C are system languages and need to be comipled Python is a general purpose programming language. That means you can use Python to write code for any programming tasks. Google search engine Mission critical projects in NASA, Processing financial transactions at New York Stock Exchange. Data Analytics
  2. Common elements in programming languages: Key Words Programmer-Defined Identifiers Operators Punctuation Syntax
  3. Loop Directories???
  4. Additionally, new functionality is added to the language all the time as it is created.