發表文章

陳安python自訂函數built-in內建函數import輸入函式庫

圖片
from math import * #陳安從math函式庫輸入所有函數 #取代原來的import math def f(r): #定義函數 define 名稱(參數),以下相同縮排都是 print("圓面積pi r*r: "+str(pi*r*r)) print("圓周長pi r*2: "+str(pi*r*2)) print("球體積pi r*r*r*4/3:"+str(pi*r*r*r*4/3)) print("球表面積pi r*r*4: "+str(pi*r*r*4)) def g(angle): print("正弦sin:"+str(sin(angle))) print("餘弦cos:"+str(cos(angle))) def h(x,y): #用在模組化你的程式碼 f(x) g(y) print("陳安:自訂函數h呼叫f,g再呼叫內建pi,sin,cos\n") h(1,pi/6)

陳安

#陳安 集合{},字典{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, 練習使用迴圈輸出集合內的內容'''

陳安python字典

圖片
w3schools截圖 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()) w3schools字典方法 確保在</h1>之後貼上才先在html模式放一個標記a Python has a set of built-in methods that you can use on dictionaries. Method Description clear() Removes all the elements from the dictionary copy() Returns a copy of the dictionary fromkeys() Returns a dictionary with the specified keys and value get() Returns the value of the specified key items() Returns a list containing a tuple for each key value pair keys() Returns a list containing the dictionary's keys pop() Removes the element with the specified key popite...

D11117238陳安JavaScript執行輸入字串再反向輸出JS Code編輯Java

圖片
JavaScript輸出結果 陳安輸入字串: JavaScript程式碼 <p>陳安輸入字串:<input id="in" len="50" type="text" /></p> <p><input onclick="f()" type="button" value="陳安執行JavaScript" /></p> <p id="out"></p> <script> function f(){ var a = document.getElementById("in").value;/*取得id=in的文字*/ var b = "源字串: "+a+"<br>長度是:" + a.length+"<br>反串是: "; var c = ""; for (var i = 0; i < a.length; i++) c = a.slice(i,i+1) + c ; b = b +"<font size=7>"+ c+"</font>"; document.getElementById("out").innerHTML = b; } </script> 微軟VS Code編輯Java程式

陳安w3schools學習Java迴圈,int整數,String字串,Character.toString將字碼轉成字元方法(函數)

圖片
/*陳安2022/10/17w3Schools學雙迴圈,運算子operator,運算元operand*/ public class Main { public static void main(String[] args) { int i, j; /*宣告整數integer變數i, j*/ String a="第", b="列:"; /*宣告整數字串a, b給初始值*/ for ( i = 8; i > 0; i--) { /*迴圈*/ System.out.print(a + i + b);/*+運算子用在字串,串接功能*/ for ( j = 0; j

金一甲

圖片
陳安利用w3schools學習HTML,CSS,Borders 德 明 陳 安 Html上的物件,稱為元素body, p=paragraph, div=division 使用專業程式碼編輯器JCRATOR 程式設計影片138