Min sum in python assignment expert

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at Thank you

Sum of 1 series

This Program name is Sum of 1 series. Write a Python program to Sum of 1 series, it has two test cases

The below link contains Sum of 1 series question, explanation and test cases

//drive.google.com/file/d/1M5N-yqq2LYyV05d-ThnD_SQ59nm9b1Vb/view?usp=sharing

We need exact output when the code was run

N = int[input[ " Enter the input: "]]


sum = 0


for i in range[N]:
  z = [10**[i+1] - 1]/ 9
  sum += z
print[sum]

Learn more about our help with Assignments: Python

Highest Sum of Scores

The students in the class were divided into groups of three.Each student was given a T-shirt for a game.Later they were asked to calculate the score of their group by adding the jersey numbers on the T-shirt of every member.Find the group with the highest scores and print the jersey numbers on the T-shirts of every group member.

Input

The first line of the input contains an integer N that denotes the number of groups.

The next N lines of input contains the scores of students in the group separated by comma.

Output

The output contains the scores of the students of the group with maximum sum separated by space.

Explanation

Given the input lists are [[0,1,2],[3,1,0]].

The sum of the scores is highest in the group[3,1,0] i.e., 4.So the output should be 3 1 0.

Sample Input1

2

0,1,2

3,1,0

Sample Output1

3 1 0

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    We can have an application for finding the lists with the minimum value and print it. This seems quite an easy task and may also be easy to code, but having shorthands to perform the same are always helpful as this kind of problem can come in web development.

    Method #1 : Using reduce[] + lambda
    The above two function can help us achieving this particular task. The lambda function does the task of logic and iteration and reduce function does the task of returning the required result. Works in python 2 only.

    test_matrix = [[1, 3, 1], [4, 5, 3], [1, 2, 4]]

    print ["The original matrix is : " + str[test_matrix]]

    res = reduce[lambda i, j: i if sum[i] < sum[j] else j, test_matrix]

    print ["Minimum sum row is : " + str[res]]

    Output :

    The original matrix is : [[1, 3, 1], [4, 5, 3], [1, 2, 4]]
    Minimum sum row is : [1, 3, 1]
    

    Method #2 : Using min[] + key
    The min function can get the minimum of all the list and key is used to specify on what the min condition has to be applied that is summation in this case.

    test_matrix = [[1, 3, 1], [4, 5, 3], [1, 2, 4]]

    print ["The original matrix is : " + str[test_matrix]]

    res = min[test_matrix, key = sum]

    print ["Minimum sum row is : " + str[res]]

    Output :

    The original matrix is : [[1, 3, 1], [4, 5, 3], [1, 2, 4]]
    Minimum sum row is : [1, 3, 1]
    


    Chủ Đề