盧魚-python教學

@LuYu-python

Public team

Community (0)
No community contribution yet

Joined on Jul 8, 2022

  • a799:正值國 內容:   很久很久以前,有一個國家叫做「正值國」,這個國家的人做什麼事都非常正直,做人坦蕩蕩。也因此,國家平安和樂、生活富足。 但是,這個國家有一個不成文的習俗,就是他們不喜歡負數,他們把負數視為邪惡的象徵,所以他們非常討厭看到負數。他們只要看到負數,就會直接把負號去掉,例如”-1”會變成”1”。 筱華是剛從其他國家搬來正值國的一位中學生,他每次只要在數學考卷上寫到負數,就會被其他同學和老師狠狠的痛打一頓,你可以幫幫他嗎? :::info 輸入說明
     Like  Bookmark
  • Turtle https://github.com/tolgaatam/ColabTurtle from ColabTurtle.Turtle import * initializeTurtle() def cube(n): for i in range(4): forward(n)
     Like  Bookmark
  • list_a = list(range(1,20,2)) print(list_a) print(list_a[5]) list_a = [1,3,5,7,9,11,13,15,17,19] print(list_a) => [1,3,5,7,9,11,13,15,17,19]
     Like  Bookmark
  • 串列 student = ["alan" , "jack" , "rose" , "bonny", "stan"] 串列+For迴圈 student = ["alan" , "jack" , "rose" , "bonny", "stan"] for name in student: print(name)
     Like  Bookmark
  • 三角形 x = 10 range(i,j) #i開始 直到j的前一個數字(i <= x < j) #range(x)= [0,1,2,3,.....,x] for i in range(0 , x): #小山:range(1,11) 我:range(0,10) = range(10) for j in range(-1 , i): #小山的好處:i一開始就是1 所以可以用range(i) 我的缺點:range(-1,i) 或者 range(i+1) print("*",end = "")
     Like  Bookmark
  • import json filename="1013//username.json" try: # 在try中放json.load()是因為如果username.json檔已經存在的話,就直接將名字載入記憶體中 with open(filename) as file: username=json.load(file) except FileNotFoundError: # 如果檔案找不到時我們會提供使用者輸入訊息並寫入檔案中以便再開啟時可以紀錄原先輸入的名字
     Like  Bookmark
  • ALICE was beginning to get very tired of sitting by her sister on the bank and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice, "without pictures or conversations?'
     Like  Bookmark
  • 方法 - count count 可以用來檢測字串中出現多少次 sen = "apple banana apple banana grape watermelon apple grape apple apple banana apple banana grape watermelon apple grape apple apple banana apple banana grape watermelon apple grape apple" find = input("選一個你想找水果") print(sen.count(find)) 模數除法(模除)
     Like  Bookmark
  • 程式習慣 - 主程式 python沒有主/副程式的概念,但寫大型程式時為了避免最外層程式雜亂,會建議用主程式的概念去寫 def AAA(): for i in range(5): print("Hello World") def __main__(): AAA()
     Like  Bookmark
  • import matplotlib.pyplot as plt list_x = [1,5,7,9,13,16] list_y = [15,50,80,40,70,50] plt.plot(list_x,list_y) plt.show() :::danger x跟y串列的數據量要一樣,否則會出現錯誤
     Like  Bookmark
  • 7/31 https://zerojudge.tw/ShowProblem?problemid=b970 https://zerojudge.tw/ShowProblem?problemid=b877 https://zerojudge.tw/ShowProblem?problemid=f345 https://zerojudge.tw/ShowProblem?problemid=c364 第四題滿有趣的有職業工程師去做,做完的心得:
     Like  Bookmark
  • :::spoiler notion筆記 用法 {%youtube NHTMs1z88uA %} ::: :::spoiler 承威 - 燈泡 https://www.jin-hua.com.tw/webc/html/product/show.aspx?num=1903&kind=1559 https://www.jin-hua.com.tw/webc/html/product/show.aspx?num=29917&kind=2919
     Like  Bookmark
  • 遞迴練習 階乘 def Fac(n): if n > 1: return n * Fac(n-1) else: return 1 print(Fac(5))
     Like  Bookmark
  • 縮排 在python中,縮排就跟C語言的大括號一樣 age = 21 if age >= 20 : print("可以投票") else : print("不能投票")
     Like  Bookmark
  • 隨機 https://docs.python.org/zh-tw/3/library/random.html import random as rm print(rm.randint(1,1000)) print(rm.randint(1,10000)) 日期 https://docs.python.org/zh-tw/3/library/datetime.html#date-objects
     Like  Bookmark
  • 定義函式結構 def HW(): print("Hello World function") 此時只有定義,運行他不會動 HW() #輸出結果:Hello World function 傳入引數
     Like  Bookmark
  • print("Hello World") 資料型態 Interget(int) 整數 age = 22 String(str) 字串 name = "Lu-Ching-Yu"
     Like  Bookmark