發表文章

陳建騏期末考加分

圖片
from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 import math #從函式庫 math 輸入所有 * 方法 from time import * from random import * class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定必然 def __init__ initiate發起 self.cx, self.cy, self.cr = cx, cy, cr #取得中心座標cx, cy, 半徑cr self.s, self.t = s, t #取得邊角數目s,t尖銳程度,取代原來的k = s.get() self.c, self.w = c, w #取得顏色c,寬度w self.u = 2 * math.pi / self.s #使用模組 math 圓周率 pi self.x, self.y = [], [] for i in range( int(self.s * 1.5)): self.x.append(self.cx + self.cr*math.cos(i*self.u)) self.y.append(self.cy + self.cr*math.sin(i*self.u)) def drawLine(self, x0, y0, x1, y1): canvas.create_line(x0, y0, x1, y1, width = self.w, fill=self.c) def draw(self): #類別的方法 secondTime = second.get() #取得輸入的second變數,當作區域變數secondTime for i in range( int(self.s * 1.5) - self.t): self.drawLine(self.x[i], s...

陳建騏python陣列array

圖片
w3schools陣列截圖 w3schools陣列程式碼 #陳建騏拷貝自 201單元 """for x in 'Takming': #迴圈逐字元印出 print("字母: %s" % x)三引號框起註解 """ fruits = ['台積電', '鴻海', '聯發科'] #台灣市場價值最高的三公司 for x in fruits: # print ("公司: %s" % x) print(fruits) fruits.append("中華電") print("使用append") print(fruits) fruits.clear() print("使用clear") print(fruits) fruits = ['台積電', '鴻海', '聯發科', '中華電'] chicken = fruits.copy() #和 chicken = fruits 有何不同? print(chicken) fruits.append("中華電") print(fruits.count("中華電")) print(fruits.count("台積電")) for x in fruits: print(x) if x == "中華電": #判斷式是否banana print('I hate 中華電.') if x == "聯發科": #判斷式是否cherry print('I like cherry.') if x == "鴻海": #判斷式是否apple print('You are my sweet apple.') #體會到只要我有耐心與興趣,我也可以當一個專業的程式開發人員 w3schools陣列方法Array Methods Ar...

陳建騏w3schools字串str,format,slicing[::]

圖片
#陳建騏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]

圖片
程式碼 #陳建騏的第一個python程式2023/2/20 print("你在跟我哈拉嗎?") #python輸出比Java簡單太多 a ="你在跟我哈拉,狗吃屎" #python指令結尾不需要;分號 b ="貓抓鼠,師父開勞斯萊斯"#python字串單引號雙引號都可 print(a) print(b) c =a[1:5:] #取字串a的第1到5(不含),從0開始 print(c) c =a[::-1] print(c) 心得 Java輸出System.out.println():

陳建騏w3schools補考Java

圖片
w3schools學習Java程式碼 Java程式碼 public class Main { /*陳建騏2023.01.12上午w3school學java字串處理*/ public static void main(String[] args) { String a = "陳建騏哈喽哈哈哈哈";/*宣告字串型態a預設"自己打"*/ String b = ""; /*宣告字串型態b預設""*/ System.out.println("原來的字串: " + a); for (int i = 0; i

陳建騏Java預設方法length()與charAt()

圖片

陳建騏Visiual Studio Code撰寫Java程式

圖片
public class Main {/*Java類別class名稱一定要和檔名相同 */ public static void main(String[] args) { int time = 20; /*宣告整數imt和javascript宣告變數一律var */ /*javascript允許動態變數var內容可以隨時改,整數變成字串都可以*/ if (time