python語言練習9-7

來源:互聯網
上載者:User

標籤:float   logs   size   int   inpu   朋友   半徑   python   div   

我們是做練習,請大家一句代碼一句代碼自己敲出來,不熟悉就多敲幾遍,不要複製粘貼,沒有意義。

  1. Hello World!
    >>>print("Hello World!")Hello World!

     

  2. 簡單互動(互動式,檔案式)教材P19
    >>> name = input(‘請輸入姓名:‘)請輸入姓名:洪英傑>>> print("{}同學,好好學python,很有用!".format(name))洪英傑同學,好好學python,很有用!>>> print("{}大俠,好好學python,很有用!".format(name))洪英傑大俠,好好學python,很有用!>>> print("{}朋友,好好學python,很有用!".format(name))洪英傑朋友,好好學python,很有用!

     

  3. 使用者輸入兩個數字,計算並輸出兩個數字之和(嘗試用一行代碼實現)。 

     

  4. 使用者輸入三角形三邊長度,並計算三角形的面積:(海倫公式)
    >>>a = float(input(‘輸入三角形第一邊長:‘))
    輸入三角形第一邊長為:2
    >>>b = float(input(‘輸入三角形第二邊長:‘))
    輸入三角形第一邊長為:3
    >>>c = float(input(‘輸入三角形第三邊長:‘))
    輸入三角形第一邊長為:4
    #計算半周長 s = ( a + b + c ) / 2 
    #計算面積 area = ( s * ( s - a ) * ( s - b ) * ( s - c ) ** 0.5
    print (‘三角形面積為 %0.2f‘ %area)
  5. 輸入半徑,計算圓的面積。
  6. 畫一組同切圓
    >>>import turtle>>>turtle.pensize(2)>>>turtle.circle(10)>>>turtle.circle(40)>>>turtle.circle(80)>>>turtle.circle(160)

     

  7. 畫一個五角星
  8. 畫一個全黃色的五角星

思考:

  1. 畫一組同心圓。
  2. 畫國旗上的五個五角星。

python語言練習9-7

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.