Answer to Question #338929 in Python for sushmanth

Question #338929

You are given an array A consisting of N integers. 

Task

Print the sum of the elements in the array. 

Note: Some of the integers may be quite large.

Input Format

  • The first line contains a single integer N denoting the size of the array.  
  • The next line contains space-separated integers denoting the elements of the array.

Output format

Print a single value representing the sum of the elements in the array.

Constraints

1<=N<=10

 0<=a[i]<=10^10


1
Expert's answer
2022-05-09T14:54:55-0400
import math
import os
import random
import re
import sys

# Complete the aVeryBigSum function below.
def aVeryBigSum(ar):
    sum = 0
    for i in range(ar_count):
        sum = sum + int(ar[i])
    return sum

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    ar_count = int(input())

    ar = list(map(int, input().rstrip().split()))

    result = aVeryBigSum(ar)

    fptr.write(str(result) + '\n')

    fptr.close()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS