非科班同學(xué)學(xué)習(xí)Python實(shí)記

知識(shí)點(diǎn)

1. 數(shù)據(jù)結(jié)構(gòu)

  • 1.1 基礎(chǔ)數(shù)據(jù)類型

bool true false 邏輯符
int 8 整數(shù)
float 7.08 浮點(diǎn)數(shù)
....

  • 1.2 容器
    • 列表 list
    • 元組 tuple
    • 字段 dict
    • 集合 set

裝基礎(chǔ)類型的容器 盒子

  • 1.3 樣例解讀
    lst是一個(gè)變量,代表了[[1, 3, 5], [2, 4, 6]],通過=賦值給 lst,[1, 3, 5]代表了一個(gè)數(shù)組(容器),其中的3個(gè)格子是1 3 5(基礎(chǔ)類型整數(shù))。
lst=[1, 3, 5]
a=lst[0] -> 1
a=lst[1] -> 3
a=lst[2] -> 5

lst= [[1, 3, 5], [2, 4, 6]]
a = lst[0]  -> [1, 3, 5]
a=lst[0][0]  -> 1

2.方法

定義:你給0個(gè)或者多個(gè)數(shù)給它,它執(zhí)行一些操作后,返回你0個(gè)或多個(gè)結(jié)果
print(a)就是print方法,其中 a是需要打印到控制臺(tái)的元素

示例
print("hello world") 控制臺(tái)就會(huì)顯示hello world

a = "hello world"
//a的值 被2替換
a = 2
print(a)

def int add(a, b):
return a+b 

def print(a):
#寫給控制臺(tái)傳輸數(shù)據(jù)
display.show(a)

a = add(5, 4) //a = 9
b = print(a) // b null
  • 關(guān)鍵字:系統(tǒng)識(shí)別的 具有特殊意義的單詞


    方法調(diào)用流程

代碼結(jié)構(gòu)

//導(dǎo)入numpy這個(gè)包 命名為np 下面的代碼就用np代替
import numpy as np 

def int add(a, b):
return a+b 

//a() 代表a方法
def main(): //程序主入口 main方法
  //lst代表局部變量 lst代表 [[1, 3, 5], [2, 4, 6]] 
 //        A1           A2
//    1 3 5         2  4  6
  lst= [[1, 3, 5], [2, 4, 6]] 
  //數(shù)組 1 2 3 一組數(shù)
  lst=[1,2,3] 
//打印函數(shù)
  print(  type(lst) -> lst的類型 數(shù)組   )
np_lst =np.array(lst)
print(   type(np_lst)   ->  np封裝后的數(shù)組  array )
np_lst = np.array(lst, np.float類型)
print(np_lst.shape) // 2行3列
print(np_lst.size)

a=add(4,5)
print(a)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容