0% found this document useful (0 votes)
177 views3 pages

Lab 7

This document summarizes an experiment on Python tuples. It includes exercises to: 1) Find the minimum and maximum value for a particular element position in a list of tuples. 2) Check if dart coordinates hit within a dartboard of radius 10 centered at (0,0). 3) Write Python expressions for word comparisons involving length and dictionary order. 4) Take user input to fill an empty tuple with province names of Pakistan and print it.

Uploaded by

ayaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
177 views3 pages

Lab 7

This document summarizes an experiment on Python tuples. It includes exercises to: 1) Find the minimum and maximum value for a particular element position in a list of tuples. 2) Check if dart coordinates hit within a dartboard of radius 10 centered at (0,0). 3) Write Python expressions for word comparisons involving length and dictionary order. 4) Take user input to fill an empty tuple with province names of Pakistan and print it.

Uploaded by

ayaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No.

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')

(c)The letter "e" does not appear in the word "floccinaucinihilipilification."


'e' in 'floccinaucinihilipilification'

(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:

You might also like