0% found this document useful (0 votes)
377 views

PWP Practical 7 PDF

This document provides guidelines for writing practical write-ups and contains 3 programming exercises on tuples. The guidelines specify using ruled pages for write-ups, writing each practical on a new page, and completing write-ups in a timely manner. The exercises demonstrate how to create and access tuples, find the maximum and minimum number in a tuple, find repeated items in a tuple, and convert a number to words using a tuple.

Uploaded by

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

PWP Practical 7 PDF

This document provides guidelines for writing practical write-ups and contains 3 programming exercises on tuples. The guidelines specify using ruled pages for write-ups, writing each practical on a new page, and completing write-ups in a timely manner. The exercises demonstrate how to create and access tuples, find the maximum and minimum number in a tuple, find repeated items in a tuple, and convert a number to words using a tuple.

Uploaded by

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

Practical No.

GUIDELINES FOR WRITING THE PRACTICAL WRITEUP

1. Use ruled file pages for write-up of practical contents.


2. You can use both side ruled pages for the same.
3. Start each practical (experiment) write-up on new page.
4. Maintain all these practical work in a file as it will be considered for
TW (continuous assessment) of the course PWP.
5. Write question answers given and take print out of only programs or
can write it on assignment pages.
6. Complete the practical write-up in time. Don’t keep it pending.

Practical No. 7: Write Python program to perform following operations on


tuples: Create tuple, Access tuple, Update tuple, Delete tuple

1. Define empty tuple. Write syntax to create empty tuple.

Ans:
A tuple without any elements is defined as an empty tuple.
Syntax:
Tup=()

2. Write syntax to copy specific elements existing tuple


into new tuple.
Ans:

Tup1=(1,2,3,4,5)
Tup2=Tup1[2:5]
print(“Elements copied”, Tup2)
Practical No. 7

3. Compare tuple with list.


SR.NO. LIST TUPLE

1 Lists are mutable Tuples are immutable

Implication of iterations is Time- The implication of iterations is


2 consuming comparatively Faster

The list is better for performing


operations, such as insertion and Tuple data type is appropriate for
3 deletion. accessing the elements

Tuple consume less memory as


4 Lists consume more memory compared to the list

Tuple does not have many built-


5 Lists have several built-in methods in methods.

The unexpected changes and errors


6 are more likely to occur In tuple, it is hard to take place.
Practical No. 7

1. Write a python program to create a tuple and find the


minimum and maximum number from it
tup=(10,20,30,40,50)
print("Maximum Number is= ",max(tup))
print("Minimum Number is= ",min(tup))

Output:
>>> %Run exp7_1.py
Maximum Number is= 50
Minimum Number is= 10

2. Write a python program to find the repeated items of a


tuple
tup=(1,2,3,4,5,1,2,6)
repeat=[]
for i in tup:
if tup.count(i)>1:
repeat.append(i)
for x in repeat:
if repeat.count(x)>1:
repeat.remove(x)
print("Repeated items are: ",repeat)

Output:
>>> %Run exp7_2.py
Repeated items are: [1, 2]
Practical No. 7

3. Write a python program to print the number in words


tup1=('zero','one','two','three','four','five','six','seven','eight','
nine')
num=input("Enter a number: ")
word=[]
for i in num:
word.append(tup1[int(i)])
print(word)

Output:
>>> %Run exp7_3.py
Enter a number: 130
['one', 'three', 'zero']

You might also like