如下所示:
1
2
3
4
5
6
7
8
9
10
11
|
# 計算面積函數 def area(width, height): return width * height def print_welcome(name): print ( "Welcome" , name) print_welcome( "duhuifeng" ) w = int ( input ( "請輸入長方形的寬:" )) h = int ( input ( "請輸入長方形的長:" )) print ( " area =" , area(w, h)) |
運行結果:
以上這篇Python實現計算長方形面積(帶參數函數demo)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/Giser_D/article/details/83216658