1 # Please fix the BUG 2 tall = input("what is your height? (for example, 1.72)") 3 weight = input("what is your weight? (for example, 60)") 4 5 bmii = weight/(tall*tall) 6 print ("Your BMI is", bmii)
樣式二:
1 # Please fix the BUG 2 tall = input("what is your height? (for example, 1.72)") 3 weight = input("what is your weight? (for example, 60)") 4 5 bmii = weight/(tall*tall) 6 print ("Your BMI is", bmii)
樣式三:
1 // 按鍵鋼琴,利用按鈕播放音階 2 2 const int speaker=2; 3 3 const int sw[8]={4,5,6,7,8,9,10,11} ; 4 4 const int frequency[8]={523,587,659,694,784,880,988,1046}; 5 5 int i ; 6 6 int val ; 7 7 8 8 void setup() { 9 9 // put your setup code here, to run once: 10 10 for(int i=0;i<8;i++) 11 11 pinMode(sw[i],INPUT) ; 12 12 13 13 } 14 14 15 15 void loop() { 16 16 // put your main code here, to run repeatedly: 17 17 for(int i=0;i<8;i++) { 18 18 val = digitalRead(sw[i]) ; 19 19 20 20 if (val==1){ 21 21 tone(speaker,frequency[i],100) ; 22 22 } 23 23 } 24 24 25 25 }
樣式四: