作業 使用者輸入數字0 100,判斷成績,用函式

2022-08-12 11:48:20 字數 1232 閱讀 6345

1#作業

2#作業:3

#使用者輸入數字0-1004#

程式判斷:5#

數字》90,成績為a6#

數字》80,成績為b7#

數字》70,成績為c8#

數字<60,成績為d9#

嘗試用函式完成?

1011

defscore(name):

12print("

welcome to %s

".center(50,"

-")%(name.upper()))

1314

while

true:

15 choice = input("

please your input score or exit q : ")

1617

if choice == "q"

: exit()

18if

choice.isdigit():

19 choice =int(choice)

20if choice > 100:

21print("

請輸入0-100以內的數字")

22continue

23if choice == 100:

24print("

%s score is full score\n

" %(name))

25elif choice >= 90:

26print("

%s score is a\n

"%name)

27elif choice >= 80:

28print("

%s score is b\n

"%name)

29elif choice >= 60:

30print("

%s score is c\n

"%name)

31else:32

print("

%s score is d\n

"%name)

3334

35else:36

print("

請輸入0-100以內的數字")

37continue

3839 name = input("

please your input name: ")

40 score(name)

C 判斷使用者輸入是否為數字?

include include include using namespace std bool is number string str return true else return true void main int a 0 const char s cout 請輸入資料a string s...

C 判斷只能輸入數字

c 判斷只能輸入數字 2010 11 06 22 57 1.try catct 2.string ss s.text bool num false foreach char c in ss if num messagebox.show yes else messagebox.show no 3.sy...

判斷使用者輸入的是否為0 9中的數字

using system using system.collections.generic using system.linq using system.text namespace hhhhhhh console.writeline 請輸入乙個數字 string s console.readlin...