Python for security analyst

Published on
Embed video
Share video
Ask about this video

Scene 1 (0s)

Python for security analyst. COS 102. Python for security analyst COS 102.

Scene 2 (7s)

[Audio] overview Basics of programming concept in Python Writing effective Python code Data Types [String, Int, float, …] Variables Conditional Statement Iterative Statement Functions Modules and Libraries Code readability Working with Strings and Lists Putting Python into practice Writing Algorithms Using regular expressions Opening and reading files Parsing files Debugging code Exercise.

Scene 3 (37s)

[Audio] Basic Python programming concepts Programming is used to create specific set of instructions for a computer to execute tasks. The use of technology to automate these tasks, can reduce human and manual effort to perform common and repetitive tasks. Python language is an essential tool to help developers to achieve this goal. It can be used in various facets of programming, which varies from basic computations, data analysis, web dev., cybersecurity, data science and machine learning, et cetera Python is an open source language embodied with a standard library for developers round the world. Their community presence enjoy many contributions from talented developers. Python was designed by Guido van Rossum..

Scene 4 (1m 29s)

Writing effective python code. ADVANTAGES OF PYTHON Resembles human language Less code Easy to read Standard guidelines Online support Built-in code.

Scene 5 (1m 43s)

Writing effective code contd.. The primary interface to the Python interpreter is the commandline. Typing python in the commandline will lead you straight to the terminal. It can be represented in various IDE environment like VSCode, anaconda, Jupyter notebook, PyCharm, JetBrains etc. The IDE environment consists of coding area, the terminal, project area, and output area, etc. depending on the package being used. The configuration and installation may vary across platforms, visit your vendor for proper guideline regarding your operating system. Lets dive in.

Scene 6 (2m 34s)

[Audio] Coding Area Menu Bar Project Area Project pane Coding Area Output pane.

Scene 7 (2m 42s)

[Audio] Reserved keywords Syntax The rules that determine what is correctly structured in a computing language. Comment The # sign is used to denote a comment. It is used for readability of programs, which is ignored during runtime. Variable A container to store data. and as assert break class continue def del elif else except exec finally for from global if import in is lambda not or pass print raise return try while with yield.

Scene 8 (3m 16s)

[Audio] Data Types Category of a particular type of data items. It focus on strings, integer, float, double, et cetera String data – consists of an ordered sequence of characters. It could be letters, symbols or numbers, which is enclosed with a double quote “ ”. Float data – consists of a number with a decimal point. Integer data – consists of positive numbers without a decimal place. Boolean data – can only be one of two values; either true or false. List data – data structure that consists of a collection of data in sequential form..

Scene 9 (3m 56s)

[Audio] Conditional statement A statement that evaluates code to determine if it meets a specified set of conditions. Keywords: If – starts a conditional statement. Else – precedes a code section that evaluates when all conditions that precede it within the conditional statement evaluate to False. Operators: > greater than = greater than equal to <= less than equal to == equal to != not equal to.

Scene 10 (4m 23s)

[Audio] Iterative statements Codes that repeatedly executes a set of instructions. They are also referred to as loops. Setting up a loop allows us to repeatedly use a line of code without having to type it multiple times. Types of loops: For loop – signals the beginning of a for loop. While loop – repeatedly executes in sequence, but this repetition is based on a condition. Loop variable – a variable used to control the iterations of a loop..

Scene 11 (4m 55s)

[Audio] functions Functions – automate task that can be reused anything in the code. Types of function Built in functions exists within Python and can be called directly. Eg: type() – returns the data type of this input. print() – used for output in the code range() – generates a sequence of numbers. max() – returns the largest numeric input passed into it. sorted() – sorts the components of a list. User defined functions are designed by programmers for specific needs. Eg: def keyword – placed before a function name to define a function. Parameter – an object that is included in a function definition for use in that function. Argument – the data bought into a function when it is called. Return statement – a python statement that executes inside a function and sends information back to the function call. It is used to return information from a function..

Scene 12 (5m 59s)

[Audio] functions. functions. 68 69 70 71 72 73 # define a function to greet employees def greet_employee(name) : print("We1come ! You're logged in. name) # call a function greet_emp10yee("Char1ie Patel").

Scene 13 (6m 18s)

[Audio] Modules and libraries Library – a collection of modules that provide code users can access in their programs. Module – a Python file that contains additional functions, variables, and any kind of runnable code. Python standard library – an extensive collection of usable python code that often comes packaged with Python. eg; re, C-S-V--, glob, os, time, datetime, et cetera.

Scene 14 (6m 48s)

[Audio] Code readability Style guide – a manual that informs the writing, formatting, and design documents. PEP 8 style guide – a resource that provides stylistic guidelines for programmers working with python. Comment – a note programmers make about their intentions behind their code. Indentation – space added at the beginning of a line of code..

Scene 15 (7m 13s)

[Audio] Working with strings and lists String data – consists of an ordered sequence of characters. A string is enclosed with double or single quotation marks. It can also be stored in a variable. Str() – converts the input object into a string. Len() – returns the number of an elements in an object. String concatenation – the process of joining two strings together. String Method – a function that belongs to specific data type. Upper() – returns a copy of the string in uppercase letters. Lower() – returns a copy of the string in all lowercase letters. Index() – finds the first occurrence of the input in a string and returns its location. String are immutable – cannot be changed after it is created and assigned a value..

Scene 16 (8m 10s)

[Audio] Lists List concatenation – combining two lists into one by placing the elements of the second list directly after the elements of the first list. Methods : insert() – adds an element in a specific position inside a list. remove() – removes the first occurrence of a specific element in a list. append() – adds input to the end of a list. re.findall() – returns a list of matches to a regular expression. open() – used to open a file in python. read() – converts files into string. split() – converts a string into a list..

Scene 17 (8m 54s)

[Audio] Putting python into practice Finding IP addresses in a set of local addresses..

Scene 18 (9m 14s)

[Audio] Writing algorithms An Algorithm is a set of rules that solve a problem. It takes a set of inputs of the problem processes it and returns a certain solution as an output. Steps in problem solving; Use string slicing to extract the first 3 digits from one IP address. Use a loop to apply that solution to every IP address on the list. For loop Counter variable If statement.

Scene 19 (9m 41s)

[Audio] Using regular expressions Regex – a sequence of characters that forms a pattern. Example of regex: plus sign – represents one or more occurrences of a specific character. Like a plus sign matches any length in the distribution. \w sign – matches with any alphanumeric character but it doesn’t match symbols. \w plus sign – matches both specific and alphanumeric characters. Note: an email address [email protected] – contains these characters \w plus @ \w plus \. \w plus for all matching characters contained in an email..

Scene 20 (10m 23s)

[Audio] Opening and reading files With – handles errors and manages external resources..

Scene 21 (10m 47s)

[Audio] Parsing files The process of converting data into a more readable format is known as parsing..

Scene 22 (11m 12s)

[Audio] Debugging code The practice of identifying and fixing errors in code. Types of errors Syntax errors – invalid usage of the python grammatical expression. Logical errors – may not cause error messages, but they may produce unintended results. Expressions – occurs when the program doesn’t know how to execute code..

Scene 23 (11m 37s)

[Audio] exercise. exercise. 256 257 258 259 260 261 Program 1 Swap two variables input ("Enter first value (a): input ("Enter second value (b) : print (f "After swapping: a.

Scene 24 (12m 1s)

[Audio] Exercise. Exercise. 316 317 318 319 320 # Program 9 # Reserve a sting input("Enter a string: ") text = reserved _ text = text[: print (f "Reserved string:" ).

Scene 25 (12m 25s)

[Audio] The end Hope this makes your acquaintance.