發表文章

詹凱慧python集合set串列或清單list字典dictionary元組tuple

圖片
w3schools截圖 w3schools程式碼 #詹凱慧 集合{},字典{key:value,},元組(),清單] s= {"台積電", "鴻海", "聯發科"} t= ("台積電", "鴻海", "聯發科") list= ["台積電", "鴻海", "聯發科"] d= {2330:"台積電",2317:"鴻海",2454:"聯發科"} print("型態" + str(type(s)) + str(s)) print("型態" + str(type(t)) + str(t)) print("型態" + str(type(d)) + str(d)) print("型態" + str(type(list)) + str(list)) #字串與字串才能+所以要用str轉成字串 i = 0 for a in list: i = i+1 print("台灣第" + str(i) + "大的公司是") print(" " + a) '''大區域註解用三個引號set集合沒有順序unordered, 練習使用迴圈輸出集合內的內容''' w3schools集合方法 Python has a set of built-in methods that you can use on sets. Method Description add() Adds an element to the set clear() Removes all the elements from the set copy() Returns a copy of the set difference() Returns a set containing the difference between two or more sets difference_update...

詹凱慧python字典

圖片
a = { #台灣股票市場價值最大,詹凱慧python 2330: "台積電", 2317: "鴻海", 2454: "聯發科", 2412: '中華電'} print(a) print("用迴圈印出所有值") for t in a: print(a[t] +" 用get()方法 " + a.get(t)) a.update({1108:"幸福"}) print(a) a.popitem() print(a) a.update({6505:"台塑化"}) a.update({2308:"台達電"}) print(a.keys()) print("練習values方法") print(a.values()) print("練習items方法") print(a.items())

w3school練習

圖片
#詹凱慧strings可以用單引雙引只要對稱 b = '狗吃屎,兔吃菜,貓抓鼠,詹凱慧很美' # 0 1 23 4 5 678 9 10,11,12, print('字串長度' + str(len(b))) #len函數 字串長度 輸出 整數 #str函數 轉成字串 這樣才能串接 print(b[-5:-2]) #練習字串格式format quantity = "精華下午茶" itemno = 5 price = "詹凱慧" myorder = "我要吃 {} 吃幾個 {},和 {} 誰一起吃" print(myorder.format(quantity, itemno, price))

詹凱慧python,print,input,字串方法[::-1]

圖片
w3schools 微軟Visiual Stuvio Code編寫python程式 微軟Visiual Stuvio Code編寫python程式碼

VS CODE編輯JAVA程式

圖片
import java.util.Scanner; /*開啟套件package util=utility用途,Scanner掃描器*/ /* 詹凱慧utility industry=公用事業產業,電力,自來水,效用=utility */ class MyClass { public static void main(String[] args) { String a, b=""; /*定義字串a,b */ Scanner myObj = new Scanner(System.in); /*建構掃描物件*/ System.out.print("輸入: "); a = myObj.nextLine(); /*輸入文字nextLine到變數a */ System.out.println("長度: " + a.length());/*輸出字串長度length() */ for (int i = 0; i

詹凱慧Java方法length(),charat(),EXCEL函數LEN,MID

圖片
w3schools練習Java length(),charAt() Java程式碼 public class Main { /*詹凱慧2022.12.26德明科大財金一甲*/ public static void main(String[] args) { String a = "狗吃屎,貓抓鼠,老猴愛作怪", b = ""; System.out.println("原來: " + a); int c = a.length(); /*方法length()*/ System.out.println("長度: "+ c); for (int i = 0; i 維基百科VS Code功能 Visual Studio Code 預設支援非常多的程式語言,包括 JavaScript、TypeScript、CSS 和 HTML;也可以透過下載擴充元件支援 Python、C/C++、Java 和 Go 在內的其他語言[14]。支援功能包括語法突顯、括號補全、程式碼摺疊和程式碼片段;對於部分語言,可以使用 IntelliSense[15]。Visual Studio Code 也支援除錯 Node.js 程式。和 GitHub 的 Atom一樣,Visual Studio Code 也基於 Electron 框架構建[16]。 Visual Studio Code 支援同時打開多個目錄,並將資訊儲存在工作區中以便復用[17]。 作為跨平台的編輯器,Visual Studio Code 允許使用者更改檔案的頁碼、換行符號和程式語言。 參見 張貼者: 詹凱慧HTML,CSS,JavaScript

詹凱慧Java遞迴函數Recursion

圖片
public static void main(String[] args) { int x =11; /*Java程式必須以main起始*/ for (int i = 0; i 0) { return k + sum(k - 1); } else {return 0; } } /*函數sum呼叫自己,稱遞迴*/ public static int f(int k) { if (k > 0) { return k * f(k - 1); } else {return 1; } } /* 0!=1, 7!=7*6!,....*/ } public class Main { /*詹凱慧 recursion遞迴函數*/ public static void main(String[] args) {