Discuss / Python / 练习

练习

Topic source

方法一:

g1 = 72

g2 = 85

r = (g2-g1)/g1

p = r*100

print('The grade of Xiao Ming has increased by: %.1f %%' % p)

方法二:

g1 = 72

g2 = 85

r = (g2-g1)/g1

p = r*100

print('The grade of Xiao Ming has increased by: {0:.1f}%.'.format(p))

方法三:

g1 = 72

g2 = 85

r = (g2-g1)/g1

p = r*100

print(f'The grade of Xiao Ming has increased by: {p:.1f}%')


  • 1

Reply