Python從入門到精通第二章習題

2021-10-08 22:09:58 字數 1288 閱讀 8212

'''

1,2,3,4四個數字組成無重複數字的3位數

'''def

_21():

for a in

range(1

,5):

for b in

range(1

,5):

for c in

range(1

,5):

if a != b and b != c and a != c:

print

(a, b, c)

# _21()

'''根據利潤分級獎金

'''def

_22():

profit =

eval

(input

('請輸入當月利潤(單位:萬元):'))

if profit >10:

bonus =1+

(profit -10)

*0.075

if profit >20:

bonus =

1.75

+(profit -20)

*0.05

if profit >40:

bonus =

2.75

+(profit -40)

*0.03

if profit >60:

bonus =

3.35

+(profit -60)

*0.015

if profit >

100:

bonus =

3.95

+(profit -

100)

*0.01

else

: bonus = profit*

0.1print

('應發獎金為:'

, bonus,

'萬元'

)# _22()

'''乙個整數加上100是乙個完全平方數,再加上168又是乙個完全平方數,求該數

'''def

_23():

x =1while x:

a =pow(x+

100,

0.5)

b =pow(x+

268,

0.5)

if a ==

int(a)

and b ==

int(b)

:print

(x)break

else

: x +=

1# _23()

JAVA從入門到精通讀書筆記 第二章

1.識別符號 由數字,字母,下劃線,符號組成。不能以數字開頭。2.識別符號的大小寫習慣。包名 使用小寫字母 類名,介面名 每個單詞的首字母大寫 方法名,成員變數名 第乙個單詞的首字母小寫,其餘單詞的首字母大寫 區域性變數名 全部小寫 常量 全部大寫 3.訪問修飾符關鍵字 public 可以被所有類訪...

Python從入門到精通

大神請繞路而走,本文適合入門小白 python基礎 python 資料型別和變數 python 字串和編碼 python 使用list和tuple python 條件判斷和迴圈 python 使用dict和set 函式python 呼叫函式 python 定義函式 python 函式的引數 pyth...

第二章 入門

第二章 入門 1 django 安裝 使用 django 的唯一先決條件是安裝 python 在 linux 平台可能包括如下步驟 2 tar xzvf django tar.gz。3 cd django 4 sudo python setup.py install。2 匯入 django模組 im...