Posts

Showing posts with the label sum of array

Python exercise with solutions (Set 4)

Image
  1.To find the smallest and largest number in the given set of numbers. Input format : The first line of input contains n numbers separated by space. Output format : Print the smallest number and largest number. Sample input : 4 1 6 8 3 2 9 0 Sample Output : The smallest number is 0 The largest number is 9 Code : Output : 2.Sum of array elements with the corresponding elements on reversing the array Given an array A of n numbers the program should print the sum of the elements of array A with the corresponding elements of the reverse of the array A. Input format : The first line should contain the number of elements n in the array. The second line contain an array of n numbers separated by space. Output format : Print the resultant array elements separated by space. Sample input : 4 3 5 8 1 Sample Output : 4 13 13  4 Explanation : The array is [3,5,8,1] The reverse of the array is [1,8,5,3] The sum of both the above arrays =>[4,13,13,4] Code : Output : 3.Multiple of 5 Given a list