SlideShare a Scribd company logo
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)

More Related Content

What's hot

Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Syed Zaid Irshad
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
Python
PythonPython
Python
Aashish Jain
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
Samir Mohanty
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ayshwarya Baburam
 
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
QA TrainingHub
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python
Jaganadh Gopinadhan
 
Python Intro
Python IntroPython Intro
Python Intro
Tim Penhey
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
Priyanka Pradhan
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
TMARAGATHAM
 
Python
PythonPython
Python ppt
Python pptPython ppt
Python ppt
Mohita Pandey
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1Kanchilug
 
Introduction to Python Programming language.pptx
Introduction to Python Programming language.pptxIntroduction to Python Programming language.pptx
Introduction to Python Programming language.pptx
BharathYusha1
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
Chariza Pladin
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Agung Wahyudi
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 

What's hot (20)

Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Python
PythonPython
Python
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to 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
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python Let’s Learn Python An introduction to Python
Let’s Learn Python An introduction to Python
 
Python Intro
Python IntroPython Intro
Python Intro
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Python
PythonPython
Python
 
Python ppt
Python pptPython ppt
Python ppt
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
Introduction to Python Programming language.pptx
Introduction to Python Programming language.pptxIntroduction to Python Programming language.pptx
Introduction to Python Programming language.pptx
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python basic
Python basicPython basic
Python basic
 

Viewers also liked

Processing Regex Python
Processing Regex PythonProcessing Regex Python
Processing Regex Python
primeteacher32
 
Reading and Writing Files
Reading and Writing FilesReading and Writing Files
Reading and Writing Files
primeteacher32
 
CSV File Manipulation
CSV File ManipulationCSV File Manipulation
CSV File Manipulation
primeteacher32
 
Sending Email
Sending EmailSending Email
Sending Email
primeteacher32
 
Web Scraping
Web ScrapingWeb Scraping
Web Scraping
primeteacher32
 
More Perl Basics
More Perl BasicsMore Perl Basics
More Perl Basics
primeteacher32
 
More Pattern Matching With RegEx
More Pattern Matching With RegExMore Pattern Matching With RegEx
More Pattern Matching With RegEx
primeteacher32
 
File I/O
File I/OFile I/O
File I/O
primeteacher32
 
Processing with Regular Expressions
Processing with Regular ExpressionsProcessing with Regular Expressions
Processing with Regular Expressions
primeteacher32
 
Matching with Regular Expressions
Matching with Regular ExpressionsMatching with Regular Expressions
Matching with Regular Expressions
primeteacher32
 
Passing Arguments
Passing ArgumentsPassing Arguments
Passing Arguments
primeteacher32
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
primeteacher32
 
Subroutines
SubroutinesSubroutines
Subroutines
primeteacher32
 
Basic .Net Training in Hyderabad
Basic .Net Training in HyderabadBasic .Net Training in Hyderabad
Basic .Net Training in Hyderabad
Ugs8008
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No RegretsAlex Ezell
 
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
Rustamji Institute of Technology
 
Python Programming - II. The Basics
Python Programming - II. The BasicsPython Programming - II. The Basics
Python Programming - II. The Basics
Ranel 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
 

Viewers also liked (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
 

Similar to Python Basics

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
 
Python ppt
Python pptPython ppt
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
 
Python basics
Python basicsPython basics
Python basics
TIB Academy
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
Amr Alaa El Deen
 
Review Python
Review PythonReview Python
Review Python
ManishTiwari326
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 
Python Basics by Akanksha Bali
Python Basics by Akanksha BaliPython Basics by Akanksha Bali
Python Basics by Akanksha Bali
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
lailoesakhan
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
Akhil Kaushik
 
Module-1.pptx
Module-1.pptxModule-1.pptx
Module-1.pptx
Manohar Nelli
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introduction
stn_tkiller
 
Introduction To Python.pptx
Introduction To Python.pptxIntroduction To Python.pptx
Introduction To Python.pptx
Anum Zehra
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
ansariparveen06
 
Operators loops conditional and statements
Operators loops conditional and statementsOperators loops conditional and statements
Operators loops conditional and statements
Vladislav Hadzhiyski
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
Prakash Jayaraman
 
Lecture1_introduction to python.pptx
Lecture1_introduction to python.pptxLecture1_introduction to python.pptx
Lecture1_introduction to python.pptx
MohammedAlYemeni1
 

Similar to Python Basics (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
 
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
 
Lecture1_introduction to python.pptx
Lecture1_introduction to python.pptxLecture1_introduction to python.pptx
Lecture1_introduction to python.pptx
 

More from primeteacher32

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

More from 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
 

Recently uploaded

0624.speakingengagementsandteaching-01.pdf
0624.speakingengagementsandteaching-01.pdf0624.speakingengagementsandteaching-01.pdf
0624.speakingengagementsandteaching-01.pdf
Thomas GIRARD BDes
 
New Explore Careers and College Majors 2024
New Explore Careers and College Majors 2024New Explore Careers and College Majors 2024
New Explore Careers and College Majors 2024
Dr. Mary Askew
 
一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理
yuhofha
 
'Guidance and counselling- role of Psychologist in Guidance and Counselling.
'Guidance and counselling- role of Psychologist in Guidance and Counselling.'Guidance and counselling- role of Psychologist in Guidance and Counselling.
'Guidance and counselling- role of Psychologist in Guidance and Counselling.
PaviBangera
 
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
atwvhyhm
 
Exploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical CommunicatorsExploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical Communicators
Ben Woelk, CISSP, CPTC
 
lab.123456789123456789123456789123456789
lab.123456789123456789123456789123456789lab.123456789123456789123456789123456789
lab.123456789123456789123456789123456789
Ghh
 
labb123456789123456789123456789123456789
labb123456789123456789123456789123456789labb123456789123456789123456789123456789
labb123456789123456789123456789123456789
Ghh
 
一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理
一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理
一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理
pxyhy
 
在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样
在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样
在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样
2zjra9bn
 
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdfRECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
AlessandroMartins454470
 
一比一原版(UVic毕业证)维多利亚大学毕业证如何办理
一比一原版(UVic毕业证)维多利亚大学毕业证如何办理一比一原版(UVic毕业证)维多利亚大学毕业证如何办理
一比一原版(UVic毕业证)维多利亚大学毕业证如何办理
pxyhy
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
mmorales2173
 
Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.
alexthomas971
 
Andrea Kate Portfolio Presentation.pdf
Andrea Kate  Portfolio  Presentation.pdfAndrea Kate  Portfolio  Presentation.pdf
Andrea Kate Portfolio Presentation.pdf
andreakaterasco
 
一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理
一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理
一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理
taqyed
 
Erection Methodology (KG Marg) MLCP.pptx
Erection Methodology (KG Marg) MLCP.pptxErection Methodology (KG Marg) MLCP.pptx
Erection Methodology (KG Marg) MLCP.pptx
zrahman0161
 
Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...
Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...
Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...
dsnow9802
 
Lbs last rank 2023 9988kr47h4744j445.pdf
Lbs last rank 2023 9988kr47h4744j445.pdfLbs last rank 2023 9988kr47h4744j445.pdf
Lbs last rank 2023 9988kr47h4744j445.pdf
ashiquepa3
 
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdfDOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
Pushpendra Kumar
 

Recently uploaded (20)

0624.speakingengagementsandteaching-01.pdf
0624.speakingengagementsandteaching-01.pdf0624.speakingengagementsandteaching-01.pdf
0624.speakingengagementsandteaching-01.pdf
 
New Explore Careers and College Majors 2024
New Explore Careers and College Majors 2024New Explore Careers and College Majors 2024
New Explore Careers and College Majors 2024
 
一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理一比一原版(YU毕业证)约克大学毕业证如何办理
一比一原版(YU毕业证)约克大学毕业证如何办理
 
'Guidance and counselling- role of Psychologist in Guidance and Counselling.
'Guidance and counselling- role of Psychologist in Guidance and Counselling.'Guidance and counselling- role of Psychologist in Guidance and Counselling.
'Guidance and counselling- role of Psychologist in Guidance and Counselling.
 
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
原版制作(RMIT毕业证书)墨尔本皇家理工大学毕业证在读证明一模一样
 
Exploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical CommunicatorsExploring Career Paths in Cybersecurity for Technical Communicators
Exploring Career Paths in Cybersecurity for Technical Communicators
 
lab.123456789123456789123456789123456789
lab.123456789123456789123456789123456789lab.123456789123456789123456789123456789
lab.123456789123456789123456789123456789
 
labb123456789123456789123456789123456789
labb123456789123456789123456789123456789labb123456789123456789123456789123456789
labb123456789123456789123456789123456789
 
一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理
一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理
一比一原版(SFU毕业证)西蒙弗雷泽大学毕业证如何办理
 
在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样
在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样
在线制作加拿大萨省大学毕业证文凭证书实拍图原版一模一样
 
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdfRECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
RECOGNITION AWARD 13 - TO ALESSANDRO MARTINS.pdf
 
一比一原版(UVic毕业证)维多利亚大学毕业证如何办理
一比一原版(UVic毕业证)维多利亚大学毕业证如何办理一比一原版(UVic毕业证)维多利亚大学毕业证如何办理
一比一原版(UVic毕业证)维多利亚大学毕业证如何办理
 
Full Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptxFull Sail_Morales_Michael_SMM_2024-05.pptx
Full Sail_Morales_Michael_SMM_2024-05.pptx
 
Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.Personal Brand Exploration Comedy Jxnelle.
Personal Brand Exploration Comedy Jxnelle.
 
Andrea Kate Portfolio Presentation.pdf
Andrea Kate  Portfolio  Presentation.pdfAndrea Kate  Portfolio  Presentation.pdf
Andrea Kate Portfolio Presentation.pdf
 
一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理
一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理
一比一原版(U-Barcelona毕业证)巴塞罗那大学毕业证成绩单如何办理
 
Erection Methodology (KG Marg) MLCP.pptx
Erection Methodology (KG Marg) MLCP.pptxErection Methodology (KG Marg) MLCP.pptx
Erection Methodology (KG Marg) MLCP.pptx
 
Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...
Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...
Jill Pizzola's Tenure as Senior Talent Acquisition Partner at THOMSON REUTERS...
 
Lbs last rank 2023 9988kr47h4744j445.pdf
Lbs last rank 2023 9988kr47h4744j445.pdfLbs last rank 2023 9988kr47h4744j445.pdf
Lbs last rank 2023 9988kr47h4744j445.pdf
 
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdfDOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
DOC-20240602-WA0001..pdf DOC-20240602-WA0001..pdf
 

Python Basics

  • 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)

Editor's Notes

  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.