Phần 26 KHÓA ĐÀO TẠO TÍNH TOÁN ỔN ĐỊNH VÀ ỨNG DỤNG TRÊN PHẦN MỀM PSSE CHO KỸ SƯ HỆ THỐNG ĐIỆN (Ngôn ngữ lập trình Python và ứng dụng trên Phần mềm PSSE)

87 883 10
Phần 26 KHÓA ĐÀO TẠO TÍNH TOÁN ỔN ĐỊNH VÀ ỨNG DỤNG TRÊN PHẦN MỀM PSSE CHO KỸ SƯ HỆ THỐNG ĐIỆN (Ngôn ngữ lập trình Python và ứng dụng trên Phần mềm PSSE)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

KHÓA ĐÀO TẠO TÍNH TOÁN ỔN ĐỊNH VÀ ỨNG DỤNG TRÊN PHẦN MỀM PSSE CHO KỸ SƯ HỆ THỐNG ĐIỆN (Ngôn ngữ lập trình Python và ứng dụng trên Phần mềm PSSE): • Basic Syntax• Variables• Control Flow Tools• BuiltIn Functions and Methods• UserDefined Functions• Files and Directories

TRANSMISSION & DISTRIBUTION A Division of Global Power POWER SYSTEM STABILITY CALCULATION TRAINING D13 It d ti t Pth D ay 13 - I n t ro d uc ti on t o P y th on December 4, 2013Prepared by: Mohamed El Chehaly eBook for You OUTLINE 2 OUTLINE • Basic Syntax • Variables • Control Flow Tools • Built-In Functions and Methods • User-Defined Functions • Files and Directories eBook for You 3 BASIC SYNTAX BASIC SYNTAX eBook for You Introduction 4 BASIC SYNTAX Introduction  Easy to learn, powerful programming tool  Efficient high level data structures  Efficient high - level data structures  Simple but effective approach to object- oriented programming oriented programming  Programs in Python much shorter than equivalent C C++ or Java programs: equivalent C , C++ or Java programs:  Complex operations can be expressed in a single statement  Statement grouping is done by indentation instead of beginning and ending brackets  Nibl tdlti  N o var i a bl e or argumen t d ec l ara ti ons are necessary eBook for You Introduction 5 BASIC SYNTAX Introduction  Interpreted: It is processed at runtime by the interpreter and you do not need to the interpreter and you do not need to compile your program before executing it  Interactive: You can actually sit at a  Interactive: You can actually sit at a Python prompt and interact with the inter p reter directl y py  Object-oriented: Python supports style or technique of programming that encapsulates code within Objects  Beginner’s language: Great language for beginner programmers eBook for You Python Basic Syntax 6 BASIC SYNTAX Python Basic Syntax  Interactive mode programming  Open IDLE (Python GUI)  Open IDLE (Python GUI) eBook for You Python Basic Syntax 7 BASIC SYNTAX Python Basic Syntax  Interactive mode programming  Write the following  Write the following print “Hello; Python!” eBook for You Python Basic Syntax 8 BASIC SYNTAX Python Basic Syntax  Script mode programming  Open new window  Open new window eBook for You Python Basic Syntax 9 BASIC SYNTAX Python Basic Syntax  Script mode programming  Write the following  Write the following print “Hello, Python!” eBook for You Python Basic Syntax 10 BASIC SYNTAX Python Basic Syntax  Script mode programming  Save as “Hello Python py”  Save as “Hello Python . py”  Run module eBook for You [...]... operators supported by Python 32 CONTROL FLOW TOOLS Operators eBook for You  Python arithmetic operators 33 CONTROL FLOW TOOLS Operators eBook for You  Python arithmetic operators 34 CONTROL FLOW TOOLS Operators  Python comparison operators eBook for You a=10 and b=20 35 CONTROL FLOW TOOLS Operators  Python assignment operators eBook for You a=10 and b=20 36 CONTROL FLOW TOOLS Operators  Python bitwise... You  Statements in Python typically end with a new line  Continuation on next line allowed with “\” 16 BASIC SYNTAX  Python accepts single (‘), double (“) and triple (‘’’ or “””) quotes to denote string  The same types of quote should start and end the string d th t i  The triple quotes can be used to span the string across multiple lines ti lti l li eBook for You Quotation in Python 17 BASIC SYNTAX... strongly private identifier  If the identifier also ends with two trailing underscores, the identifier is a language-defined special name eBook for You  Python is case sensitive (name and Name) C Convention f P th ti for Python 13 BASIC SYNTAX Python Identifiers eBook for You  Reserved words 14 BASIC SYNTAX  Blocks of code for class and function definitions or flow control denoted by line indentation... 25 VARIABLES  Most versatile of Python s compound data types  A list contains items separated by commas and enclosed within square brackets “[ ]”  All the items belonging to a list can be of different data type  The values stored in a list can be accessed using the slice operator “[ ]” with indexes starting at 0 in the beginning of the list eBook for You Lists 26 VARIABLES Lists >>> list1 = [ ‘abcd’,...11 BASIC SYNTAX Python Identifiers  Variable  Function  Class  Module  Other objects j  Starts with  Letter A to Z  Letter a to z  Underscore  No punctuation characters such as @,$,% eBook for You  Name used to identify 12 BASIC SYNTAX Python Identifiers  Class names start with an uppercase letter  Starting an identifier... point real values  complex: complex numbers  Numbers with different base can be represented  Binary: start with 0B or 0b  Octal: start with 0O or 0o  Hexadecimal: start with 0x or 0X eBook for You  Python supports four different numerical types 23 VARIABLES Numbers eBook for You  Examples  Complex numbers a = 2.1+3.14j a.real = 2 1 l 2.1 a.Imag = 3.14 24 VARIABLES Strings >>>str1 = 'Hello World!‘... comment  All characters after the # and up to the physical line end are part of the comment h i l li d t f th t  A line can be commented by ALT+3 and uncommented by ALT+4 t db eBook for You Comments in Python 18 BASIC SYNTAX Waiting for the User  The program will wait for the user to press the Enter key  Here “\n\n” are being used to create two new lines before displaying the actual line  This is... cannot be updated  Tuples can be thought of as read-only lists eBook for You Tuples 28 VARIABLES  Kind of hash table type C Consist of key-value pairs i t fk l i  A dictionary key can be almost any Python type but are usually numbers or strings  Values can be an arbitrary values  Di ti Dictionaries are enclosed by curly braces i l db l b “{ }” and values can be accessed using brackets “[ ] [ ]”... the th prompt “Press the enter key to exist.” t “P th t k t i t” VARIABLES eBook for You 19 20 VARIABLES Standard Data Type  Numbers  List  Tuple  Dictionary eBook for You  String g 21 VARIABLES  Python variables do not have to be explicitly declared  The declaration happens automatically when you assign a value to a variable eBook for You Assigning Values to Variables 22 VARIABLES Numbers  int: . programmers eBook for You Python Basic Syntax 6 BASIC SYNTAX Python Basic Syntax  Interactive mode programming  Open IDLE (Python GUI)  Open IDLE (Python GUI) eBook for You Python Basic Syntax 7 BASIC. SYNTAX Python Basic Syntax  Script mode programming  Save as “Hello Python py”  Save as “Hello Python . py”  Run module eBook for You Python Identifiers 11 BASIC SYNTAX Python . Control Flow Tools • Built-In Functions and Methods • User-Defined Functions • Files and Directories eBook for You 3 BASIC SYNTAX BASIC SYNTAX eBook for You Introduction 4 BASIC SYNTAX Introduction 

Ngày đăng: 16/08/2014, 15:22

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan