發表文章

圖片
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], se...

謝宇哲類別class __init__(self, 其他參數)

圖片
class Person: #建立類別,必須有 兩底線init兩底線的起始initiate函數 def __init__(self, name, age): self.name = name self.age = age def myfunc(self): print("嗨!我的") print("名字是" + self.name) print("嗨!我的\n名字是" + self.name) #字串中\n換列 p1 = Person("謝宇哲", 36) p1.myfunc() print("印出p1.name: " + p1.name) 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*...
from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 from math import * #從函式庫 math 輸入所有 * 方法 class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定 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 * 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*cos(i*self.u)) self.y.append(self.cy + self.cr*sin(i*self.u)) def draw(self): #類別的方法 for i in range( int(self.s * 1.5) - self.t): canvas.create_line(self.x[i], self.y[i], self.x[i + self.t], self.y[i + self.t], fill = self.c, width = self.w) def show(): #畫圖 poly = Regular(cx.get(), cy.get(), cr.get(), s.get(), t.get(), c.get(), w.get()) polyList.append(poly) polyList[len(polyL...

謝宇哲Python集合set清單list元組tuple字典dictionary

圖片

..

圖片
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())

謝宇哲python,print,input,字串方法

圖片
w3school #註解:謝宇哲2023/2/20 w3school.com print("謝宇哲超帥") a="聽說他給女生的分數較高" print(a) b=a[3:9:] print(b) c=a[2:9:2] print(c) d=a[9:2:-1] print(d) a = input("自己輸入字串:") print("你輸入:"+a) print("反過來:"+a[::-1])

D11117115謝宇哲JavaScript執行輸入字串再反向輸出Java

圖片
pre{border: sold blue} JavaScript輸出結果 謝宇哲輸入字串: JavaScript程式碼 <p>謝宇哲輸入字串:<input type="text" len="50" id="in"></p> <p><input type="button" value="謝宇哲執行JavaScript" onclick="f()"></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程式 Java程式碼 import java.util.Scanner; /*開啟套件package util=utility用途,Scanner掃描器*/ /*謝宇哲utility industry=公用事業產業,電力,自來水,效用=utility */ class MyClass { public static void main(String[] args) { String a, b="...