Bài đăng

Hiển thị các bài đăng có nhãn Python

Bài ôn tập chương 1 - Quan trọng

Bảng chú giải những thứ vô cùng quan trọng 1.     A general process for solving a category of problems - algorithm Một quá trình chung để giải quyết cho một hạng mục của các vấn đề - thuật toán 2.     an error in a program - bug Một lỗi trong chương trình - bug (để nguyên vì không cần phải dịch) 3.     an intermediate language between source code and object code - byte code Một ngôn ngữ trung gian giữa mã nguồn và mã đối tượng người ta gọi là - byte code 4.     To translate a program written in a high-level language into a low-level language all at once, in preparation for late execution. – compile Để dịch một chương trình viết trong một ngôn ngữ cấp cao thành một ngôn ngữ cấp thấp trong một lần, trong quá trình chuẩn bị cho việc thực thi cuối gọi là - Biên soạn 5.     The process of finding and removing any of the three kinds of programming errors. – debugging Quá trình tìm kiếm và xử lý (xóa ...

2.6. Statements and Expressions

http://media.interactivepython.org/thinkcsVideos/Expressions.mov A   statement   is an instruction that the Python interpreter can execute. We have only seen the assignment statement so far. Some other kinds of statements that we’ll see shortly are   while   statements,   for statements,   if   statements, and   import   statements. (There are other kinds too!) Một câu lệnh là một chỉ thị mà trình biên dịch Python có thể thực thi. Chúng ta có thể nhìn thấy câu lệnh được giao gần đây. Một vài loại khác của câu lệnh chúng ta mà chúng ta có thể nhìn như câu lệnh white, for, if, import (Cũng có những loại khác) An  expression  is a combination of values, variables, operators, and calls to functions. Expressions need to be evaluated. If you ask Python to  print  an expression, the interpreter  evaluates  the expression and displays the result. Một cách biểu thức là một sự kết hợp của giá trị, biến, toán tử ...

2.4. Variables

One of the most powerful features of a programming language is the ability to manipulate variables. A variable is a name that refers to a value. Một trong những đặc điểm sức mạnh của một ngôn ngữ lập trình là khả năng vận dụng của các biến. Một biến là một cái tên (có thể coi là nhãn) mà dẫn tới 1 giá trị. Assignment statements create new variables and also give them values to refer to. Câu lệnh gán tạo một biến mới và đưa chúng những giá trị để tham khảo. message = "What's up, Doc?" n = 17 pi = 3.14159 This example makes three assignments. The first assigns the string value "What's up, Doc?" to a new variable named message. The second gives the integer 17 to n, and the third assigns the floating-point number 3.14159 to a variable called pi. ví dụ này tạo ra 3 nhiệm vụ. Nhiệm vụ đầu tiên là (gán) chuỗi giá trị "What's up, Doc?" cho một biến tên message. (Nhiệm vụ) thứ 2 là đưa ra số nguyên 17 cho n, và  (nhiệm vụ) thứ 3 là định dạn...

2.3. Type conversion functions

Reference http://interactivepython.org/runestone/static/thinkcspy/SimplePythonData/Typeconversionfunctions.html Sometimes it is necessary to convert values from one type to another. Python provides a few simple functions that will allow us to do that. The functions  int ,  float  and  str  will (attempt to) convert their arguments into types  int ,  float  and  str  respectively. We call these  type conversion  functions. Đôi lúc thực sự cần thiết để chuyển đổi các giá trị từ định dạng này sang loại khác. Python cung cấp một vài hàm đơn giản sẽ giúp chúng ta làm điều đó. Những hàm int, float và str sẽ (cố gắng để) chuyển đổi các đối số thành dạng số nguyên (int) số thập phân (float) và chuỗi tương ứng. Chúng ta gọi chúng là các hàm chuyển đổi dạng (dữ liệu). The  int  function can take a floating point number or a string, and turn it into an int. For floating point numbers, it  discards  the deci...