# Python Program to print Max and Min Value in List of Tuples

## Max and Min Value in List of Tuples

Write a program to print the maximum and minimum of all the values at index zero and index one in the list of tuples.

Input

The first line of input will contain a positive integer (N).
The next N lines will contain space-separated two integers, denoting elements of each tuple.

Output

The first line of output should contain a tuple with the maximum and minimum value at index zero.
The second line of output should contain a tuple with the maximum and minimum value at index one.

Explanation

For example, if the given N is 3, read the inputs in the next three lines. If the inputs in the next three lines are the following.

1 5
3 2
5 8

As 5 is the maximum and 1 is the minimum in the values at index zero and 8 is the maximum and 2 is the minimum in the values at index one. So the output should be

(5, 1)
(8, 2)

Sample Input 1
4
1 2
2 5
10 1
-3 6

Sample Output 1
(10, -3)
(6, 1)

Code:

``````n = int(input())
num_list = []
zero_index_list = []
first_index_list = []

for i in range(n):
values_list = input().split()
first_value = int(values_list)
zero_index_list.append(first_value)
second_value = int(values_list)
first_index_list.append(second_value)

zero_index_min_max_tuple = (max(zero_index_list), min(zero_index_list))
first_index_min_max_tuple = (max(first_index_list),min(first_index_list))
print(zero_index_min_max_tuple)
print(first_index_min_max_tuple)``````

Input
5
6 9
2 5
4 1
7 3

Output
(7, -1)
(9, 1)

## Python Program to Convert Integer into a Single Numeral

Single Digit Number Ram is given a positive integer N .He wishes to convert this integer into a single numeral. He does so by repeatedly adding the…

## Python Program to Print Armstrong numbers between two intervals￼

Write a program to print all the Armstrong numbers in the given range A to B (including A and B). An N – digit number is an…

## Python Program to Check if Given Input is a Letter, Digit or Special Character￼

Letter, Digit or Special Character You are given a character as input. Check if the given input is a Lowercase Letter or Uppercase Letter or Digit or…

## Interleave Strings | Python Program to merge two strings by adding characters in alternating order

Interleave Strings Given two strings, write a program to merge the given two strings by adding characters in alternating order, starting with the first string. If a…

## Python Program to Check if given colors are present in the color palate

Shekhar is an artist. He likes to draw and paint. He is now drawing a portrait of a city road which is in the black color and…

## Python Program to Check the eligibility criteria for donor

Python Comparison Operators An XYZ hospital has organised a blood donation camp. The eligibility criteria for donor was as follows  1) Age>=18  2) Weight >=50 kg  3)…