Coursera 笔记

Module 01 · Python BasicsPython 基础

Module 1 Summary: Python Basics模块 1 总结:Python 基础

Coursera ↗

Congratulations! You have completed this module. At this point, you know that: 
恭喜!您已完成本模块。此时,您知道:

  • Python can distinguish among data types such as integers, floats, strings, and Booleans.
    Python 可以区分整数、浮点数、字符串和布尔值等数据类型。
  • Integers are whole numbers that can be positive or negative.
    整数是正数或负数的整数。
  • Floats include integers as well as decimal numbers between the integers.
    浮点数包括整数以及整数之间的十进制数。
  • You can convert integers to floats using typecasting and vice-versa.
    您可以使用类型转换将整数转换为浮点数,反之亦然。
  • You can convert integers and floats to strings.
    您可以转换整数和浮点数为字符串。
  • You can convert an integer or float value to True (1) or False (0).
    您可以将整数或浮点值转换为真(1)或假(0)。
  • Expressions in Python are a combination of values and operations used to produce a single result.
    Python 中的表达式是值和运算的组合,用于产生单个结果。
  • Expressions perform mathematical operations such as addition, subtraction, multiplication, and so on.
    表达式执行加法、减法、乘法等数学运算。
  • We can use // to perform integer division, which results in an integer value by discarding the fractional part.
    我们可以使用 // 进行整数除法,这将通过舍弃小数部分得到一个整数值。
  • Python follows the order of operations (BODMAS) to perform operations with multiple expressions.
    Python 遵循运算符优先级(BODMAS)来执行多个表达式的运算。
  • Variables store and manipulate data, allowing you to access and modify values throughout your code.
    变量存储和管理数据,允许您在代码中访问和修改值。
  • The assignment operator "=" assigns a value to a variable.
    赋值运算符“=”将值赋给变量。
  • ":" denotes the value of the variable within the code.
    ":" 表示代码中变量的值。
  • Assigning another value to the same variable overrides the previous value of that variable.
    给同一变量赋值另一个值将覆盖该变量的上一个值。
  • You can perform mathematical operations on variables using the same or different variables.
    您可以使用相同或不同的变量对变量进行数学运算。
  • Modifying the value of one variable will affect other variables only if they reference the same mutable object.
    修改一个变量的值只会影响其他变量,前提是它们引用的是同一个可变对象。
  • Python string operations involve manipulating text data using tasks such as indexing, concatenation, slicing, and formatting.
    Python 字符串操作涉及使用索引、连接、切片和格式化等任务来操作文本数据。
  • A string is usually written within double quotes or single quotes, including letters, white space, digits, or special characters.
    字符串通常用双引号或单引号书写,包括字母、空白、数字或特殊字符。
  • A string attaches to another variable and is an ordered sequence of characters.
    字符串附加到另一个变量上,是一个字符的有序序列。
  • Characters in a string identify their index numbers, which can be positive or negative.
    字符串中的字符识别它们的索引号,这些索引号可以是正数或负数。
  • We use strings as a sequence to perform sequence operations. 
    我们使用字符串作为序列来执行序列操作。
  • You can input a stride value to perform slicing while operating on a string.
    您可以在操作字符串时输入步长值以进行切片。
  • Operations like finding the length of the string, combining, concatenating, and replicating, result in a new string.
    字符串的查找长度、合并、连接和复制等操作,将生成一个新的字符串。
  • You cannot modify an existing string; they are immutable. 
    您不能修改现有的字符串;它们是不可变的。
  • You can use escape sequences with a backslash (\) to change the layout of a string. (For example, \n for a new line, \t for a tab, and \\ for a backslash, etc.)
    您可以使用反斜杠(\)作为转义序列来更改字符串的布局。(例如,\n 用于换行,\t 用于制表符,\\ 用于反斜杠等。)
  • In Python, you perform tasks such as searching, modifying, and formatting text data with its pre-built string methods functions.
    在 Python 中,您可以使用其预构建的字符串方法函数执行搜索、修改和格式化文本数据等任务。
  • You apply a method to a string to change its value, resulting in another string. 
    您将一种方法应用于字符串以更改其值,从而得到另一个字符串。
  • You can perform actions such as changing the case of characters in a string, replacing items in a string, finding items in a string, and so on using pre-built string methods.
    您可以使用预定义的字符串方法执行诸如更改字符串中字符的大小写、替换字符串中的项目、在字符串中查找项目等操作。