python3輸入正整數(shù)n求各位數(shù)字平方和?
s = input("請輸入一個正整數(shù):") ls = list(s) num = [] for i in ls: num.append(eval(i)
) sum = 0 for j in num: sum += pow(j, 2) print("輸入的正整數(shù)是:{},各位數(shù)字平方和是:{}".format(s, sum))
python3輸入正整數(shù)n求各位數(shù)字平方和?
s = input("請輸入一個正整數(shù):") ls = list(s) num = [] for i in ls: num.append(eval(i)
) sum = 0 for j in num: sum += pow(j, 2) print("輸入的正整數(shù)是:{},各位數(shù)字平方和是:{}".format(s, sum))