网络编程
位置:首页>> 网络编程>> Python编程>> python 输入一个数n,求n个数求乘或求和的实例

python 输入一个数n,求n个数求乘或求和的实例

作者:aaakirito  发布时间:2022-06-06 01:44:36 

标签:python,求乘,求和

求和


try:
while True:
 n=input()
 s=1
 for x in raw_input().split():
  s=s+int(x)
 print s
except EOFError:
exit()

求乘


try:
while True:
 n=input()
 s=1
 for x in raw_input().split():
  s=s*int(x)
 print s
except EOFError:
exit()

来源:https://blog.csdn.net/aaakirito/article/details/79306546

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com