高階程式設計技術課後作業 第五章練習

2021-08-17 14:05:42 字數 2456 閱讀 8945

5-2 更多的條件測試

**:

print("abc"=="abc")

print("aaa"=="bbb")

print("abc"=="abc")

print("abc".lower()=="abc")

print(1 > 2

and2 > 1)

print(1 >2

or2 > 1)

list = ['a','b','c','d']

print('a'inlist)

print('a'not inlist)

結果:

true

false

false

true

false

true

true

false

5-6 人生的不同階段

**:

age = 5

ifage>=0

andage < 2:

print("這是個嬰兒")

elifage >= 2

andage < 4:

print("他在蹣跚學步")

elifage >= 4

andage <13:

print("他是兒童")

elifage >= 13

andage < 20:

print("他是青少年")

elifage >= 20

andage < 65:

print("他是成年人")

else:

print("他是老人")

結果:

他是兒童

5-10 檢查使用者名稱

**:

current_users = ["amy","john","lily","mike","tom"]

new_users = ["amy","john","levy","king","levy"]

current_users_lower = [i.lower()foriincurrent_users]

fornew_userinnew_users:

ifnew_user.lower()incurrent_users_lower:

print(new_user +" is existed.please use other name")

else:

print("succeesfully register "+ new_user)

print(current_users)

結果:amy is existed.please use other name

john is existed.please use other name

succeesfully register levy

succeesfully register king

levy is existed.please use other name

['amy', 'john', 'lily', 'mike', 'tom', 'levy', 'king']

高階程式設計技術課後作業 第七章練習

7 3 10的整數倍 num int input 請輸入乙個數字 ifnum 10 0 print 這個數字是10的整數倍 else print 這個數字不是10的整數倍 結果 請輸入乙個數字 100 這個數字是10的整數倍 請輸入乙個數字 99 這個數字不是10的整數倍 7 5 電影票 messa...

高階程式設計技術 sklearn課後作業

作業要求 1 create a classification dataset n samples 1000,n features 10 2 split the dataset using 10 fold cross validation 3 train the algorithms gaussian...

第五章多表連線練習和課後作業

練習 課後作業 1.顯示員工smith的姓名,部門名稱,直接上級名稱 select e.ename 員工姓名,d.dname 部門名稱,mgr.ename 直接上級名稱 from emp e,dept d,emp mgr where e.deptno d.deptno and e.mgr mgr.e...