0% found this document useful (0 votes)
4 views32 pages

Python Basics for Engineering Applications

Uploaded by

danin5454
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views32 pages

Python Basics for Engineering Applications

Uploaded by

danin5454
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Python for

Engineering Applications
Types of Programming Language
High level language: Python
• Human friendly
• Require compiler/interpreter to translate to machine
language
• Less memory efficiency compared to low level language

Low level language:


• Machine friendly
• Harder for user to interpret & understand
• Require assembler to translate to machine language
Types of Programming Methods

Programming
Methods

Object
Procedural Functional Logic
Oriented
Programming Programming Programming
Programming

Python
What is Python?

• Programming language developed by Guido Van


Rossum and released in 1991
• High level programming language, used for:
– Web application/development back-end (server side)
– Software development
– Mathematical analysis
– Data science
– etc
Why Python?

• Easy to understand with simple syntax (beginner


friendly)
• Cross-platform
• Fast growing modules and libraries
• Open source
• Large active comunity
Python Installation
[Link]
Python Installation
Python Installation
Python Libraries

• Python libraries are a collection of modules and


functions for different purposes so user do not
have to write the code from scratch.
• Python has its own built-in libraries and it also
allows to use third-party libraries which are
developed and maintained by Python user
community.
Python Libraries

Useful built-in libraries:


• math
• datetime
• pathlib
• os
• random

[Link]
Python Libraries

Useful third-party libraries:


• Matplotlib – data visualisation
• Numpy – scientific computing
• Scipy – scientific computing
• Pandas – data analysis
• PyTorch – Artificial Intelligence
• etc
PIP

• Python libraries are generally installed by using PIP.


• PIP is package manager for Python, which is
included by default starting from Python version 3.4
or later.
• To install libraries using PIP, open ‘command
prompt’ by typing ‘cmd’ in windows search box
• The command to install can be found in the
corresponding library website or in
[Link]
PIP
Installing library

Uninstalling library

Check installed libraries


Importing Library to Python

Import the whole


objects from the
library

Import specific objects


from the library
Integrated Development Environment
(IDE)
VSC Installation
[Link]
Setting Up VSC for PYHTON
Setting Up VSC for PYTHON
Run Your First Python Program
Python Essentials

• Single line comment:

• Multi-line comment:

• Indentation:
Variables, Objects and Classes

• Object is a collection of data along with


functions that can operate on that data.
• Variable is a name that is used to reference to an
object.
VARIABLES OBJECTS

LIST_1 [1, 2, 3]

NAME “TESTING”

TOTAL 225
Variables, Objects and Classes
• Object is a collection of data along with functions
that can operate on that data.
• Variable is a name that is used to reference to an
object.
• Class is an object constructor.
VARIABLES OBJECTS

LIST_1 [1, 2, 3]

NAME “TESTING”

TOTAL 225
Variables, Objects and Classes
Variables, Objects and Classes
Data Types

String Integer Float

Complex List Tuple

Sets Dictionary Boolean


Data Types - String

• String is a collection of alphabets, words or other


characters.
• To present a string, we need to wrap it with either
single (’) or double quotation (’’).
• Double quote allows us to embed single quote in
the string
Data Types - Integer, Float & Complex

• Integer is a number either positive or negative


without decimals.
• Float is a floating point number (real numbers +
decimals). The maximum value of floating
number in Python is approximately 1.8e+308.
• Complex is a used to represent both complex and
imaginary part of numbers. The imaginary part is
represented by ‘j’.
Data Types - List & Tuple

• List is a mutable and indexed object and used to


store multiple items in a single variable. List is
written using [] bracket.

• Tuple is an immutable and indexed object and


used to store multiple items in a single variable.
List is written using () bracket.
Data Types - Sets

• Sets is an immutable and unindexed object and


used to store multiple items in a single variable.
No duplicate is allowed.
Data Types - Dictionary

• Dictionary is used to store multiple items in


keys/value pairs. Dictionary is mutable and
indexed, but does not allow duplicate.

Ryan

Jessie
Data Types - Boolean

• Boolean is used to represent two values including


’’True’’ or ’’False’’
• Boolean is typically used to evaluate an
expression and get one of the above answers.
Math Operations

You might also like