1. 程式人生 > >day02 作業答案

day02 作業答案

1. 

(1).false   (2).false

2. 

(1).8  (2).4

3. 

(1).6  (2).3  (3).false (4).3   (5).true   (6).true  (7).0  (8).3  (9).0 (10).2

4.

(1).while True:

  迴圈體

    else:

  跳出迴圈執行這裡

5.

count=1
while 1:
    number
=input("猜猜我的數字:") if int(number)==66: print("回答正確") break elif int(number)< 66: print("猜小了") else : print("猜大了")

6.

count=1
while 1:
    number=input("猜猜我的數字:")
    if int(number)==66:
        print("回答正確")
        break
    elif count ==2:
        
print("太笨了") count=count+1

7.

count=1
while count<=10:
    print(count)
    count+=1

8.

count=1
sum=1
while count<=99:
    count += 1
    sum=sum+count
print(sum)

9.

count=1
while count<=100:
    if count %2!=0:
        print(count)
    count += 1

10.

count=1
while
count<=100: if count %2==0: print(count) count += 1

11.

sum=1
count=1
while count<99:
    count=count+1
    if count %2 ==0:
        sum=sum-count
    else :
        sum=sum+count

12.

count=1
while count<=3:
    username = input('請輸入使用者名稱:')
    password = input("請輸入密碼:")
    if username=='apple' and password =='123456':
        print('登陸成功')
        break
    else :
        print("登陸失敗")
        print("還剩"+str(3-count)+"")
    count=count+1

13.

 

14.

a=''
b='第一'
c='稀缺'
d='國家級'
ad=input("輸入廣告:")
if (a  or b  or c or d) in ad:
    print("不合法")
else:
    print('合法')