Python Introduction Chapter One PDF

Summary

This document provides an introduction to the Python programming language, specifically focused on its use in cybersecurity. It covers various aspects of Python, including its core features, properties, use cases, and different IDEs. Topics discussed include Python's role in scripting, system management, graphic design, and more. The document emphasizes its extensive libraries for rapid application development and dynamic typing.

Full Transcript

Chapter One : Introduction to python By: Fatima Mhammed AbuHjeela Cyber Security Department JUST, Jordan What is python? Object oriented language Interpreted language Supports dynamic data type Independent from platforms Focused on development time...

Chapter One : Introduction to python By: Fatima Mhammed AbuHjeela Cyber Security Department JUST, Jordan What is python? Object oriented language Interpreted language Supports dynamic data type Independent from platforms Focused on development time Simple and easy grammar High-level internal object data types Automatic memory management It’s free (open source) 2 Language properties Indentation for block structure Dynamic typing Everything is an object No main in the language 3 Python! Useful as a scripting language ▪ script: A small program meant for one-time use ▪ Targeted towards small to medium sized projects Used by: ▪ Google, Yahoo!, Youtube ▪ Many Linux distributions ▪ Games and apps 4 Python uses System management (i.e., scripting) Graphic User Interface (GUI) Internet programming Database (DB) programming Text data processing Distributed processing Numerical operations Graphics Cyber Security Data Science Artificial Intelligence Machine Learning 5 Python for Cyber Security Python is one of the most useful programming languages for cybersecurity considering its: Extensive library of powerful packages that supports Rapid Application Development (RAD) Clean syntax code and modular design Automatic memory management and dynamic typing capability Mixed code environments to combine different programming languages (MicroPython, Cython, Jython, Skulpt (JS), PyPy) It can perform a multitude of cybersecurity functions, including malware analysis, scanning, and penetration testing tasks. 6 Python for Cyber Security Developers can do any of the following without using any other third-party tools: Web server fingerprinting Simulation of attacks Port scanning Website cloning Load generation and testing of a website Creating intrusion detection and prevention systems Wireless network scanning Transmission of traffic in the network Accessing mail servers 7 Python libraries for Cyber Security 8 Python Vs.Java ▪ Code 5-10 times more concise ▪ Dynamic typing ▪ Much quicker development no compilation phase less typing ▪ Yes, it runs slower but development is so much faster! ▪ Similar (but more so) for C/C++ ▪ Use Python with Java: JPython! 9 Installing Python Windows: Mac OS X: Download Python from Python is already installed. http://www.python.org Open a terminal and run Install Python. python or run Idle from Run Idle from the Start Menu. Finder. Download python 3.10 (Stable Linux: Release) Chances are you already have https://www.python.org/down Python installed. To check, loads/windows/ run python from the terminal. If not, install from your distribution's package system. 10 Compilers and Interpreters Programs written in high-level languages must be translated into machine language to be executed Compiler: translates high-level language program into separate machine language program ▪ Machine language program can be executed at any time 11 Compilers and Interpreters Interpreter: translates and executes instructions in high- level language program ▪ Used by Python language ▪ Interprets one instruction at a time ▪ No separate machine language program Source code: statements written by programmer Syntax error: prevents code from being translated 12 Interpreted Languages Interpreted ▪ Not compiled like Java ▪ Code is written and then directly executed by an interpreter ▪ Type commands into interpreter and see immediate results Java: Runtime Code Compiler Computer Environment Python: Code Interpreter Computer 13 Compilers and Interpreters Executing a high-level program with an interpreter 14 Compilers and Interpreters Many languages require you to compile (translate) your program into a form that the machine understands. compile execute source code byte code output Hello.java Hello.class Python is instead directly interpreted into machine instructions. interpret source code output Hello.py 15 Python Interpreter ❑The interpreter environment works using REPL: Read the lines of the code Evaluate and execute the code Print the output of the code (if any) to the console Looping to repeat the above process 16 Python IDlEs IDLE (An integrated development environment): It is a software application that offers computer programmers with extensive software development abilities. IDEs most often consist of a source code editor, build automation tools, and a debugger. 17 Python IDEs 1.PyCharm One of the widely used Python IDE which is fully featured. Supports Python web development frameworks, Angular JS, JavaScript, CSS, HTML, and live editing functions. It is well-integrated with Python console and IPython Notebook. 18 Python IDEs 2.Spyder The most suitable Python IDE for data science works. Popular for Python development which is famously used for engineers and scientists to create a secure and scientific environment for Python. 19 Python IDEs 3. Python IDLE It is a basic IDE primarily used by beginner level developer who is seeking practice of Python development. It is developed only in Python in collaboration with Tkinter GUI toolkit. 20 Python IDEs 4. Jupyter Notebook IDE specifically used for data science environment. It is an application based on a server-client structure. It enables you to create and edit notebooks. 21 Python IDEs 5. Visual Studio It is built by Microsoft and is a fully featured IDE 22 Python IDEs 6. Anaconda The Anaconda distribution is the most popular Python distribution out there. Most importable packages are pre-installed. Offers a nice GUI in the form of Spyder. 23 Python IDEs ❑ Other IDLE: Wing Thonny Rodeo Eric PyDev Sublime Text 3 Atom Etc. 24 Python Online Interprter 1.Python.org 2. Tutorial Points 3. Collaboratory 4. Repl.it 25 The Python Interpreter python IDLE Allows you to type commands one-at-a-time and see results 26 File naming conventions Python files usually end with the suffix.py Executable files usually don’t have the.py extension Modules (later) should always have the.py extension 27 Using Python Python must be installed and configured prior to use ▪ One of the items installed is the Python interpreter Python interpreter can be used in two modes: ▪ Interactive mode: enter statements on keyboard ▪ Script mode: save statements in Python script 28 Interactive Mode When you start Python in interactive mode, you will see a prompt ▪ Indicates the interpreter is waiting for a Python statement to be typed ▪ Prompt reappears after previous statement is executed ▪ Error message displayed If you incorrectly type a statement Good way to learn new parts of Python 29 Writing Python Programs and Running Them in Script Mode Statements entered in interactive mode are not saved as a program To have a program use script mode ▪ Save a set of Python statements in a file ▪ The filename should have the.py extension ▪ To run the file, or script, type python filename at the operating system command line 30 Python Scripts When you call a python program from the command line the interpreter evaluates each expression in the file. Python also has mechanisms to allow a python program to act both as a script and as a module to be imported and used by another python program 31 IDLE Development Environment IDLE is an Integrated Development Environment for Python, typically used on Windows Multi-window text editor with : syntax highlighting auto-completion smart indent. syntax highlighting. Integrated debugger with stepping persistent breakpoints call stack visibility. 32 Running Python Interactively from console: ▪ C:> python ▪ >>> print(2*3) ▪ 6 As Python module files: Interactive prompt ▪ C:> python mypgm.py No statement delimiter Python modules are text files with.py extensions 33 Our First Python Program Python does not have a main method like Java ▪ The program's main code is just written directly in the file Python statements do not end with semicolons hello.py 1 print("Hello, world!") 34

Use Quizgecko on...
Browser
Browser