Lab 7
Lab 7
07
Lab 07 –Python Tuples.
1.Use built-in min and max functions to perform the task of getting the minimum and
maximum value of in a list of tuples for a particular element position in a tuple.
Sample = [(2, 3), (4, 7), (8, 11), (3, 6)]
CODE:
OUTPUT:
2. A dartboard of radius 10 and the wall it is hanging on are represented using the two
dimensional coordinate system, with the board’s center at coordinate (0; 0). Variables x and y
store the x- and y-coordinate of a dart hit. Write an expression using variables x and y that
evaluates to True if the dart hits (is within) the dartboard, and evaluate the expression for
these dart coordinates:
(a) (0,0)
CODE:
OUTPUT:
(b) (10, 10)
CODE:
OUTPUT:
(c) (6,6)
CODE:
OUTPUT:
(d) (7,8)
CODE:
OUTPUT:
3. Write Python expressions corresponding to these statements:
(a)The number of characters in the word "anachronistically" is 1 more than the number of
characters in the word "counterintuitive."
len("anachronistically")-len("counterintuitive")
(b)The word "misinterpretation" appears earlier in the dictionary than the word
"misrepresentation."
min('misinterpretation','misrepresentation')
(d)The number of characters in the word "counterrevolution" is equal to the sum of the number
of characters in words "counter" and "resolution."
len('counterrevolution')==len('counter')+len('resolution')
4. Write a program in Python that holds an empty tuple and fill that tuple after taking user
input for names of provinces of Pakistan n fill an empty tuple and print.
CODE:
OUTPUT: