Exercise for CP1-L01

請輸入你的學號 (Write your student ID number) 例如:S05430210,請記得以S開頭。



Is your input correct? If not, please re- enter and submit again.
請確認你輸入正確,如果錯誤請重新輸入一遍再送出
這個欄位請一定要輸入,否則我們無法登錄你的成績。
如果正確請按下確認鍵




CP1-L01


Problem 1

                           
x=19                                                                            
y=5                                                                             
z=x%y                                                                           
print 'z=',z                                                                    
for i in range(1,30):                                                           
    a=i%y                                                                       
    if(a == 0):  print i                                                        
sum1,sum2=0,0                                                                   
for i in range(1,30):                                                           
    if(i%y > 2):                                                                
        sum1 += i                                                               
    else:                                                                       
        sum2 += i                                                               
print 'sum1=',sum1                                                              
print 'sum2=',sum2                                                              

仔細觀察上面的程式,並且透過程式中的註解與執行的結果,掌握每一個用法,這是未來經常會用到的基本語法。依據你執行後的結果回答下面的問題: (03小題)

(a)Z=_
可嘗試次數(no. of submission)= 2

01

(b)sum1=____
可嘗試次數(no. of submission)= 2

02

(c)sum2=___
可嘗試次數(no. of submission)= 2

03


Problem 2

                           
N=4                                                                             
sum=0                                                                           
for i in range(1, N+1):                                                         
    sum+=i                                                                      
print 'sum=',sum                                                                
print 'exact=',N*(###)/2                                                        

上面的程式做一個整數的求和運算,在螢幕上你會看到sum=___ (02小題)

sum=_____
可嘗試次數(no. of submission)= 3

04

如果我們想要加一個精確的(exact)求和公式在這個計算當中,請你將程式當中#字號的部分取代為正確的文字=___
可嘗試次數(no. of submission)= 3

05


Problem 3

                           
N=1                                                                             
for i in range(1, 5):                                                           
    N*=i                                                                        
print 'N=',N                                                                    

Run the code above, what is the output on the screen? N=____ (01小題)

N=____
可嘗試次數(no. of submission)= 3

06


Problem 4

                           
sum=0                                                                           
for i in range(1, 5):                                                           
    sum+=i**2                                                                   
print 'sum=',sum                                                                

Run the code above, what is the output on the screen? sum=____ (01小題)

sum=____
可嘗試次數(no. of submission)= 3

07


Problem 5

                           
sum=0                                                                           
for i in range(1, 5):                                                           
    sum+=i*(i+1)                                                                
print 'sum=',sum                                                                

Run the code above, what is the output on the screen? sum=____ (01小題)

sum=____
可嘗試次數(no. of submission)= 3

08


Problem 6

                           
import math                                                                     
PI=math.pi                                                                      
print 'PI=',PI                                                                  
x=PI/3.                                                                         
print 'sin(x)=',math.sin(x)                                                     
print 'cos(x)=',math.cos(x)                                                     

Run the code above, what is the output on the screen? sum=____ (03小題)

PI=____
可嘗試次數(no. of submission)= 3

09

sin(x)=____
可嘗試次數(no. of submission)= 3

10

cos(x)=____
可嘗試次數(no. of submission)= 3

11


Problem 7

                           
N=13                                                                            
for i in range(1,N,2):                                                          
    print i                                                                     
######The output is:                                                            
1                                                                               
3                                                                               
5                                                                               
7                                                                               
9                                                                               
11                                                                              
13                                                                              
15                                                                              

先觀察上面這個程式以及這個程式的輸出,請你從下面給你的程式當中加以修改,為了能夠得到下面指定的輸出,那麼你應該將程式中被隱藏的文字適當的取代之後,就可以完成這個程式 (04小題)

####the output we want:                                                         
1                                                                               
5                                                                               
9                                                                               
13                                                                              
##### the code for you to complete                                              
N=16                                                                            
FFF i in RRRRR(1,AAA):                                                          
    BBBBBBB                                                                     
 

FFF=___
可嘗試次數(no. of submission)= 3

12

RRRRR=_____
可嘗試次數(no. of submission)= 3

13

AAA=___
可嘗試次數(no. of submission)= 5

14

BBBBBBB=_______
可嘗試次數(no. of submission)= 5

15

利用下面這個連結你可以查詢你得分的情況,成績查詢網頁每30秒更新一次。
成績查詢連結