#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'N个数字的平均值'
N = 3
sum = 0
count = 0
while count < N:
num = float(input('number:'))
sum = num + sum
count += 1
average = sum / N
print(type(sum))
print("N: %s, sum: %d ,average: %.2f" % (N, sum, average))
print("N:{}, sum:{} ,average:{:.2f}".format(N, sum, average))
# print("N:{}, sum:{:d} ,average:{:.2f}".format(N, sum, average))
The last commented out line reported an error, ValueError: Unknown format code 'b' for object of type 'float'
I want to output sum, such as a floating point number such as 60.0, as an integer
Try this