import random def NumericOperations(num1,num2): print("num1=",num1,"num2=",num2) print("num1+num2=",num1+num2) print("num1-num2=",num1-num2) print("num1*num2=",num1*num2) print("num1/num2=",num1/num2) print("num1//num2=",num1//num2) #除法之商 print("num1%num2=",num1%num2) #除法之餘數 print("num1**num2=",num1**num2) #num1的num2次方 def 猜數字(): 標準答案 = random.randint(1,100) 你猜的數字 = int(input("123:")) 猜測次數 = 1 while 標準答案 != 你猜的數字: if 標準答案 < 你猜的數字: print("太大了,再猜一次! 加油") else: print("太小了,再猜一次!加油") 你猜的數字 = int(input("請輸入您所猜的整數:")) 猜測次數 = 猜測次數+1 print("猜對了!總共猜了", 猜測次數, "次") def triangle(base,high): #area=base*high/2 return (base*high/2) def tri(base,high): h=(base*base+high*high)**0.5 print(h) #return (h) def squre(x,n): ans=1 while(n>0): ans=ans*x n=n-1 return (ans) print(squre(2,10)) #print(2**10) def ex1(x,n): ans=0 while x<=n: ans=ans+x x=x+1 return (ans) print(ex1(1,100)) #1+2+3+...+99+100 #one day one apple def apple(): ans="apple" guess="" count=0 while(ans!=guess and count<10): print("一天一??,醫生遠離你,只能猜十次喔") ans=input("ans:") count=count+1 if(ans!=guess): print("十次都沒答對.......") else: print("你答對了,猜了",count,"次,答案為一天一",ans,"醫生遠離你") #apple() print(triangle(3,4)) print(tri(3,4))
2011年10月4日 星期二
100設計一甲_week3
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言