中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

音樂盒的網(wǎng)站怎么做代寫稿子的平臺(tái)

音樂盒的網(wǎng)站怎么做,代寫稿子的平臺(tái),wordpress 文檔在線瀏覽,張家界專業(yè)seo優(yōu)化文章目錄 Input & OutputVariables & Data typesPython字符串重復(fù)(字符串乘法)字符串和數(shù)字連接在一起print時(shí),要強(qiáng)制類型轉(zhuǎn)換int為str用input()得到的用戶輸入,是str類型,如果要以int形式計(jì)算的話&#xff0c…

文章目錄

  • Input & Output
    • Variables & Data types
    • Python字符串重復(fù)(字符串乘法)
    • 字符串和數(shù)字連接在一起print時(shí),要強(qiáng)制類型轉(zhuǎn)換int為str
    • 用input()得到的用戶輸入,是str類型,如果要以int形式計(jì)算的話,需要強(qiáng)制類型轉(zhuǎn)換為int
    • 我們可以只使用一個(gè)變量user_input來節(jié)省內(nèi)存
    • convert string type to date type
    • convert date to string
    • Multi-line code statement 換行符
      • 在括號(hào)內(nèi),行的延續(xù)的自動(dòng)的
    • Escape sequence 轉(zhuǎn)義字符
    • String format
      • string format 中限制輸入占位大小的同時(shí)小數(shù)點(diǎn)后位數(shù)
    • Arithmetic operators
  • Fundamentals of the Analysis of Algorithm Efficiency
    • Algorithm analysis framework 算法分析框架
      • 1. Measuring Input Sizes
      • 2. Units for Measuring Running Time
      • 3. Order of growth
      • 4. Worst-Case, Best-Case, and Average-Case Efficiency
    • Summary
    • 漸進(jìn)式符號(hào)
      • no faster
      • at least as fast as
      • at same rate
      • Summary
      • Some Properties
      • Using Limits for Comparing Orders of Growth
    • Analysis of non-recursive algorithms 非遞歸算法的分析
    • Analysis of recursive algorithms 遞歸算法的分析
      • Examples
        • 求n!
      • 重要的遞歸類型
  • For-loop
    • 字符串操作
      • 字符串內(nèi)容大寫/小寫
      • 找字串位置,找不到返回-1
      • 字符串長(zhǎng)度
      • 根據(jù)下標(biāo)返回字符串中對(duì)應(yīng)字符
      • 切割字符串
  • Data Structure
    • Abstract data type (ADT)
  • Function 函數(shù)
    • 四舍五入保留小數(shù)點(diǎn)后多少位函數(shù)
    • min,max函數(shù)是python內(nèi)置的
    • random函數(shù)
  • Class and object
    • Instance attribute vs Class attribute
    • Instance method vs Class/Static method
      • Instance method
        • Special instance method
          • `__init__` 方法
          • `__str__` 方法
          • `__repr__` 方法
          • 完整示例
      • Static / Class method
        • Class method vs static method: 類方法和靜態(tài)方法的區(qū)別
          • 類方法(Class Method)
          • 靜態(tài)方法(Static Method)
          • 示例代碼:
    • Defining class and creating object 定義類和創(chuàng)建對(duì)象
    • Accessing object instance attributes 訪問對(duì)象的實(shí)例屬性
    • Modify object instance attributes 更改對(duì)象的實(shí)例屬性
    • Defining an object instance method 定義對(duì)象的示例屬性
    • 類注釋和函數(shù)注釋
    • 案例學(xué)習(xí):定義一個(gè)學(xué)生類
    • Class inheritance 類繼承
  • Array and Linked List
    • Numpy Array
    • Python鏈表實(shí)現(xiàn)
  • Debuging
    • Exception&traceback
    • Assertion
    • Logging


Input & Output

在這里插入圖片描述

Variables & Data types

str: a string represents a sequence of characters.
int: an integer, a whole number
float: a decimal number
bool: a boolean value is either True or False.
Date data type: including year, month, day, (not the time)
Date-time data type: including year, month, day, hour, minute, second, …

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

Python字符串重復(fù)(字符串乘法)

在這里插入圖片描述

字符串和數(shù)字連接在一起print時(shí),要強(qiáng)制類型轉(zhuǎn)換int為str

在這里插入圖片描述

在這里插入圖片描述

用input()得到的用戶輸入,是str類型,如果要以int形式計(jì)算的話,需要強(qiáng)制類型轉(zhuǎn)換為int

在這里插入圖片描述

我們可以只使用一個(gè)變量user_input來節(jié)省內(nèi)存

在這里插入圖片描述

convert string type to date type

strptime
在這里插入圖片描述

convert date to string

strftime
在這里插入圖片描述

Multi-line code statement 換行符

在這里插入圖片描述

在括號(hào)內(nèi),行的延續(xù)的自動(dòng)的

Line continuation is automatic when the split comes while a
statement is inside parenthesis ( , brackets [ or braces {
在這里插入圖片描述

Escape sequence 轉(zhuǎn)義字符

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

String format

在這里插入圖片描述
在這里插入圖片描述

格式意義
<15left alignment, using 15 spaces
^25center alignment, using 25 spaces
>15right alignment, using 15 spaces

string format 中限制輸入占位大小的同時(shí)小數(shù)點(diǎn)后位數(shù)

在這里插入圖片描述
還可以通過這種方式實(shí)現(xiàn)四舍五入取整
.0f
在這里插入圖片描述

Arithmetic operators

Floor division = 地板除 = 向下取整除
在這里插入圖片描述
floor division地板除是什么意思
向下取整除,就是地板除 floor division
向上取整除,就是天花板除,ceil division

來自 https://zhuanlan.zhihu.com/p/221901326
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

Fundamentals of the Analysis of Algorithm Efficiency

Algorithm analysis framework 算法分析框架

Analysis of algorithms means to investigate an algorithm’s efficiency with respect to resources: running time and memory space
算法分析是指研究一個(gè)算法在資源方面的效率:運(yùn)行時(shí)間和內(nèi)存空間。
在這里插入圖片描述

1. Measuring Input Sizes

Efficiency is defined as a function of input size.
F(n)

2. Units for Measuring Running Time

Count the number of times an algorithm’s basic operation is executed
計(jì)算一個(gè)算法的基本操作被執(zhí)行的次數(shù)
Basic operation: the operation that contributes the most to the total
running time.
例如,基本操作通常是算法最內(nèi)部循環(huán)中最耗時(shí)的操作。

3. Order of growth

在這里插入圖片描述
在這里插入圖片描述

4. Worst-Case, Best-Case, and Average-Case Efficiency

在這里插入圖片描述
==Efficiency (# of times the basic operation will be executed) ==
在這里插入圖片描述

Average case:
Efficiency (#of times the basic operation will be executed) for a typical/random
input of size n. NOT the average of worst and best case. How to find the
average case efficiency?
平均情況。對(duì)于大小為n的典型/隨機(jī)輸入的效率(基本操作將被執(zhí)行的次數(shù)),而不是最壞和最好情況的平均值。如何找到平均案例的效率?

Summary

在這里插入圖片描述
算法的運(yùn)行時(shí)間(空間)隨著其輸入大小的增加而增長(zhǎng)的階數(shù)為無窮大。
對(duì)于相同大小的輸入,一些算法的效率可能有很大的不同

漸進(jìn)式符號(hào)

在這里插入圖片描述

no faster

在這里插入圖片描述
在這里插入圖片描述

at least as fast as

在這里插入圖片描述
在這里插入圖片描述

at same rate

在這里插入圖片描述
在這里插入圖片描述

Summary

在這里插入圖片描述

Some Properties

在這里插入圖片描述
在這里插入圖片描述
意義:算法的整體效率將由增長(zhǎng)順序較大的部分決定。

Using Limits for Comparing Orders of Growth

在這里插入圖片描述
在這里插入圖片描述

所有的對(duì)數(shù)函數(shù)loga n都屬于同一個(gè)類別
所有相同度數(shù)k的多項(xiàng)式都屬于同一類別
指數(shù)函數(shù)對(duì)于不同的a有不同的增長(zhǎng)順序
在這里插入圖片描述
在這里插入圖片描述

Analysis of non-recursive algorithms 非遞歸算法的分析

在這里插入圖片描述

Analysis of recursive algorithms 遞歸算法的分析

在這里插入圖片描述

  • 計(jì)算遞歸調(diào)用的次數(shù)
  • 解決遞歸問題,或通過后向替代或其他方法估計(jì)解決方案的數(shù)量級(jí)

Examples

求n!

在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述

重要的遞歸類型

在這里插入圖片描述
在這里插入圖片描述

For-loop

在這里插入圖片描述
range(0,10) 范圍是左閉右開

字符串操作

字符串內(nèi)容大寫/小寫

在這里插入圖片描述
.upper()
.lower()

找字串位置,找不到返回-1

在這里插入圖片描述

字符串長(zhǎng)度

在這里插入圖片描述

根據(jù)下標(biāo)返回字符串中對(duì)應(yīng)字符

在這里插入圖片描述

切割字符串

在這里插入圖片描述
[i:j] 范圍左開右閉,從下標(biāo)為i的字符到下標(biāo)為j-1的字符,獲得的子串長(zhǎng)度為j-i

Data Structure

data, relationship , operation
在這里插入圖片描述

Abstract data type (ADT)

在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述

Function 函數(shù)

在這里插入圖片描述
在這里插入圖片描述

四舍五入保留小數(shù)點(diǎn)后多少位函數(shù)

在這里插入圖片描述

min,max函數(shù)是python內(nèi)置的

在這里插入圖片描述

random函數(shù)

在這里插入圖片描述
左閉右閉

Class and object

對(duì)象是類的實(shí)例。
術(shù)語“對(duì)象”和“實(shí)例”可以互換使用。每個(gè)對(duì)象實(shí)例都有自己的數(shù)據(jù)值。
在這里插入圖片描述

Instance attribute vs Class attribute

Some information belongs to individual object instance.
Some other information is common to all objects.

  • Instance attribute: data belongs to individual object instance.
  • Class attribute: data that is common to all objects. (Some classes do not have any class attributes.)

有些信息屬于單個(gè)對(duì)象實(shí)例。
其他一些信息對(duì)于所有對(duì)象都是通用的。

  • 實(shí)例屬性:數(shù)據(jù)屬于單個(gè)對(duì)象實(shí)例。
  • 類屬性:所有對(duì)象共有的數(shù)據(jù)。 (有些類沒有任何類屬性。)

在這里插入圖片描述

Instance method vs Class/Static method

Instance method:

  • Deal with a particular individual object instance
  • The first argument (self) is always referred to the object instance
  • instance method can be invoked from an object

Static / Class method:

  • Do NOT deal with individual object instance
  • Common to all object instances
  • static/class method can be invoked from class name

實(shí)例方法:

  • 處理特定的單個(gè)對(duì)象實(shí)例
  • 第一個(gè)參數(shù)(self)始終引用對(duì)象實(shí)例
  • 可以從對(duì)象調(diào)用實(shí)例方法

靜態(tài)/類方法:

  • 不處理單個(gè)對(duì)象實(shí)例
  • 所有對(duì)象實(shí)例共有
  • 靜態(tài)/類方法可以從類名調(diào)用

Instance method

在這里插入圖片描述
在這里插入圖片描述

Special instance method

在這里插入圖片描述
在 Python 中,特殊的實(shí)例方法(也稱為魔術(shù)方法或魔法方法)在類中具有特殊的意義和用途。以下是你提到的幾個(gè)魔術(shù)方法的解釋和示例:

__init__ 方法

__init__ 方法是類的構(gòu)造函數(shù),用于初始化新創(chuàng)建的對(duì)象的屬性。它在對(duì)象創(chuàng)建時(shí)自動(dòng)調(diào)用。你可以使用它來設(shè)置對(duì)象的初始狀態(tài)。

class TV_Program:def __init__(self, channel, title, start_time, duration):self.channel = channelself.title = titleself.start_time = start_timeself.duration = duration# 創(chuàng)建一個(gè) TV_Program 對(duì)象
program = TV_Program('HBO', 'Game of Thrones', '21:00', 60)
print(program.channel)  # 輸出: HBO
__str__ 方法

__str__ 方法用于定義對(duì)象的“可讀”字符串表示。當(dāng)你使用 print() 函數(shù)或 str() 函數(shù)時(shí),Python 會(huì)調(diào)用這個(gè)方法。這個(gè)方法應(yīng)該返回一個(gè)易于閱讀和理解的字符串。

class TV_Program:def __init__(self, channel, title, start_time, duration):self.channel = channelself.title = titleself.start_time = start_timeself.duration = durationdef __str__(self):return f"{self.title} on {self.channel} at {self.start_time} for {self.duration} minutes"# 創(chuàng)建一個(gè) TV_Program 對(duì)象
program = TV_Program('HBO', 'Game of Thrones', '21:00', 60)
print(program)  # 輸出: Game of Thrones on HBO at 21:00 for 60 minutes
__repr__ 方法

__repr__ 方法用于定義對(duì)象的“正式”字符串表示。這通常是一個(gè)詳細(xì)且準(zhǔn)確的字符串,應(yīng)該盡可能包含信息,以便開發(fā)者可以重現(xiàn)該對(duì)象。__repr__ 方法通常在交互式解釋器中調(diào)用,或者當(dāng)使用 repr() 函數(shù)時(shí)調(diào)用。

class TV_Program:def __init__(self, channel, title, start_time, duration):self.channel = channelself.title = titleself.start_time = start_timeself.duration = durationdef __repr__(self):return f"TV_Program(channel='{self.channel}', title='{self.title}', start_time='{self.start_time}', duration={self.duration})"# 創(chuàng)建一個(gè) TV_Program 對(duì)象
program = TV_Program('HBO', 'Game of Thrones', '21:00', 60)
print(repr(program))  # 輸出: TV_Program(channel='HBO', title='Game of Thrones', start_time='21:00', duration=60)
完整示例
class TV_Program:def __init__(self, channel, title, start_time, duration):self.channel = channelself.title = titleself.start_time = start_timeself.duration = durationdef __str__(self):return f"{self.title} on {self.channel} at {self.start_time} for {self.duration} minutes"def __repr__(self):return f"TV_Program(channel='{self.channel}', title='{self.title}', start_time='{self.start_time}', duration={self.duration})"# 創(chuàng)建一個(gè) TV_Program 對(duì)象
program = TV_Program('HBO', 'Game of Thrones', '21:00', 60)
print(program)  # 調(diào)用 __str__ 方法
print(repr(program))  # 調(diào)用 __repr__ 方法

在這個(gè)示例中,__init__ 方法用于初始化 TV_Program 對(duì)象的屬性,__str__ 方法用于提供對(duì)象的可讀字符串表示,而 __repr__ 方法用于提供對(duì)象的正式字符串表示。

Static / Class method

在這里插入圖片描述

Class method vs static method: 類方法和靜態(tài)方法的區(qū)別
  • The first argument (cls) of a class method is always referred to the class

在這里插入圖片描述
在 Python 中,類方法和靜態(tài)方法都是屬于類的特殊方法,但它們有不同的用途和行為。以下是它們的區(qū)別和詳細(xì)解釋:

類方法(Class Method)

類方法使用 @classmethod 裝飾器定義,第一個(gè)參數(shù)總是指向類本身,通常命名為 cls。類方法可以訪問類的屬性和方法,但不能直接訪問實(shí)例屬性。

特點(diǎn):

  1. 第一個(gè)參數(shù) cls 代表類,而不是實(shí)例。
  2. 可以通過類名或者實(shí)例調(diào)用。
  3. 可以訪問類屬性和類方法,不能訪問實(shí)例屬性。

示例:

class Student:email_domain = "solla.sollew.edu"  # 類屬性@classmethoddef admin_email(cls):return "admin@" + cls.email_domain  # 訪問類屬性# 調(diào)用類方法
print(Student.admin_email())  # 輸出: admin@solla.sollew.edu# 創(chuàng)建實(shí)例并調(diào)用類方法
student = Student()
print(student.admin_email())  # 輸出: admin@solla.sollew.edu
靜態(tài)方法(Static Method)

靜態(tài)方法使用 @staticmethod 裝飾器定義。靜態(tài)方法沒有默認(rèn)的參數(shù),它們與類和實(shí)例都無關(guān),不能訪問類屬性或?qū)嵗龑傩?。靜態(tài)方法通常用于一些邏輯上與類相關(guān),但不需要訪問類或?qū)嵗娜魏螖?shù)據(jù)的方法。

特點(diǎn):

  1. 沒有默認(rèn)的參數(shù)(沒有 selfcls)。
  2. 可以通過類名或者實(shí)例調(diào)用。
  3. 無法訪問類屬性和實(shí)例屬性。

示例:

class Student:email_domain = "solla.sollew.edu"  # 類屬性@staticmethoddef uni_website():return "http://www.solla.sollew.edu"  # 邏輯上與類相關(guān),但不訪問類或?qū)嵗臄?shù)據(jù)# 調(diào)用靜態(tài)方法
print(Student.uni_website())  # 輸出: http://www.solla.sollew.edu# 創(chuàng)建實(shí)例并調(diào)用靜態(tài)方法
student = Student()
print(student.uni_website())  # 輸出: http://www.solla.sollew.edu
示例代碼:

總結(jié):

  • 類方法 使用 @classmethod 裝飾,第一個(gè)參數(shù) cls 代表類本身,可以通過類名或?qū)嵗{(diào)用,能訪問類屬性和類方法。
  • 靜態(tài)方法 使用 @staticmethod 裝飾,沒有默認(rèn)參數(shù),不能訪問類屬性或?qū)嵗龑傩?#xff0c;只是邏輯上與類相關(guān)的方法。
class Student:email_domain = "solla.sollew.edu"  # 類屬性student_dir = "/user/student"  # 類屬性@classmethoddef admin_email(cls):return "admin@" + cls.email_domain  # 類方法,訪問類屬性@staticmethoddef uni_website():return "http://www.solla.sollew.edu"  # 靜態(tài)方法,不訪問類或?qū)嵗龜?shù)據(jù)# 調(diào)用類方法和靜態(tài)方法
print(Student.admin_email())  # 輸出: admin@solla.sollew.edu
print(Student.uni_website())  # 輸出: http://www.solla.sollew.edu# 創(chuàng)建實(shí)例并調(diào)用類方法和靜態(tài)方法
student = Student()
print(student.admin_email())  # 輸出: admin@solla.sollew.edu
print(student.uni_website())  # 輸出: http://www.solla.sollew.edu

在這里插入圖片描述

Defining class and creating object 定義類和創(chuàng)建對(duì)象

在這里插入圖片描述

Accessing object instance attributes 訪問對(duì)象的實(shí)例屬性

在這里插入圖片描述

Modify object instance attributes 更改對(duì)象的實(shí)例屬性

在這里插入圖片描述

Defining an object instance method 定義對(duì)象的示例屬性

在這里插入圖片描述

類注釋和函數(shù)注釋

在這里插入圖片描述

案例學(xué)習(xí):定義一個(gè)學(xué)生類

在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

Class inheritance 類繼承

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

Array and Linked List

Numpy Array

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

Python鏈表實(shí)現(xiàn)

在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

Debuging

Exception&traceback

在這里插入圖片描述
在這里插入圖片描述
traceback庫(kù)中的traceback.format_exc()獲取異常追蹤的詳細(xì)信息

Assertion

? 它通常用于檢查不可能發(fā)生的情況
? 斷言語句導(dǎo)致終止
立即停止 → 快速失敗
? 對(duì)于來自程序員而不是用戶的錯(cuò)誤
在這里插入圖片描述

在這里插入圖片描述

Logging

  • 使用 print() 向用戶顯示某些變量的值顯示消息
  • Logging日志模塊在屏幕上顯示日志信息/向程序員顯示信息文件

在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述

http://m.risenshineclean.com/news/65603.html

相關(guān)文章:

  • 深圳建站公司模板網(wǎng)絡(luò)營(yíng)銷公司排行
  • 怎么制作app網(wǎng)站千萬不要去電商公司上班
  • 制作網(wǎng)站公司年收入多少百度指數(shù)關(guān)鍵詞未收錄怎么辦
  • 平安做計(jì)劃書的網(wǎng)站人力資源培訓(xùn)
  • 網(wǎng)站建設(shè)公司專業(yè)的建站優(yōu)化公司百度seo怎么優(yōu)化
  • 每月網(wǎng)站流量網(wǎng)絡(luò)營(yíng)銷常用的工具
  • 加關(guān)鍵詞的網(wǎng)站石家莊網(wǎng)站seo外包
  • 上海網(wǎng)站企業(yè)軟文推廣是什么
  • 網(wǎng)站后期維護(hù)收費(fèi)熱門網(wǎng)站排名
  • 貿(mào)易網(wǎng)站建設(shè)sem投放是什么意思
  • 網(wǎng)頁制作工具的選擇與網(wǎng)站整體風(fēng)格網(wǎng)絡(luò)廣告推廣服務(wù)
  • 老司機(jī)做爰網(wǎng)站老師影音百度托管運(yùn)營(yíng)哪家好
  • 家裝設(shè)計(jì)師培訓(xùn)學(xué)校湖南企業(yè)seo優(yōu)化推薦
  • 新手做網(wǎng)站做什么樣的網(wǎng)站建設(shè)公司哪個(gè)好呀
  • 怎么在微信做企業(yè)網(wǎng)站app開發(fā)費(fèi)用標(biāo)準(zhǔn)
  • 有哪些設(shè)計(jì)的很優(yōu)秀的網(wǎng)站企業(yè)培訓(xùn)內(nèi)容
  • 沈陽智能模板建站軟文營(yíng)銷范文100字
  • 武漢軟件100強(qiáng)企業(yè)名單北京官方seo搜索引擎優(yōu)化推薦
  • 資陽網(wǎng)站設(shè)計(jì)搜狗搜索網(wǎng)
  • 互聯(lián)網(wǎng)行業(yè) 英文郴州seo網(wǎng)絡(luò)優(yōu)化
  • 濟(jì)南做網(wǎng)站多少錢站長(zhǎng)工具pr值查詢
  • 全免費(fèi)云游戲網(wǎng)頁在線玩seo快速排名軟件價(jià)格
  • 東莞seo網(wǎng)站推廣個(gè)人怎么做免費(fèi)百度推廣
  • 重慶網(wǎng)站建設(shè)有限公司拼多多運(yùn)營(yíng)
  • 網(wǎng)站運(yùn)營(yíng)模式有哪些短網(wǎng)址鏈接生成
  • 現(xiàn)在最靠譜的購(gòu)物網(wǎng)站有哪些天津seo實(shí)戰(zhàn)培訓(xùn)
  • 網(wǎng)站開發(fā)師培訓(xùn)網(wǎng)絡(luò)營(yíng)銷手段有哪四種
  • 深圳網(wǎng)站開發(fā)優(yōu)化營(yíng)商環(huán)境 助推高質(zhì)量發(fā)展
  • 建設(shè)一個(gè)網(wǎng)站需要提供什么手續(xù)seo網(wǎng)絡(luò)推廣專員
  • 十堰建設(shè)網(wǎng)站首頁無錫seo公司