0% found this document useful (0 votes)
12 views2 pages

Practical No 7: Ex1: Create A Tuple and Find The Minimum and Maximum Number From It

The document contains three practical exercises in Python programming. The first exercise demonstrates how to create a tuple and find its minimum and maximum values. The second exercise identifies repeated items in a tuple, and the third exercise converts a number into its corresponding word representation.
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)
12 views2 pages

Practical No 7: Ex1: Create A Tuple and Find The Minimum and Maximum Number From It

The document contains three practical exercises in Python programming. The first exercise demonstrates how to create a tuple and find its minimum and maximum values. The second exercise identifies repeated items in a tuple, and the third exercise converts a number into its corresponding word representation.
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/ 2

Practical No 7

Ex1: Create a tuple and find the minimum and maximum


number from it.
# Create a tuple and find the minimum and maximum number from it.
numTuple = (1,2,42,42,13,41,24,3,-1)
min = numTuple[0]
max = numTuple[0]
print("numTuple = ",numTuple)
for i in range(len(numTuple)):
if(min > numTuple[i]):
min = numTuple[i]
if(max < numTuple[i]):
max = numTuple[i]
print("Minimum Number of The numTuple Is :",min)
print("Maximum Number of The numTuple Is :",max)

Output:
PS F:\Python\Practicals\7> python ex1.py
numTuple = (1, 2, 42, 42, 13, 41, 24, 3, -1)
Minimum Number of The numTuple Is : -1
Maximum Number of The numTuple Is : 42

Ex2: Write a Python program to find the repeated items of a


tuple.
# Write a Python program to find the repeated items of a tuple.
numTuple = (1,2,42,42,13,41,24,3,-1,3)
repeated_items = []
for i in range(len(numTuple)):
if (numTuple.index(numTuple[i]) != i ):
repeated_items.append(numTuple[i])
print("Repeated Numbers In numTuple Are :",repeated_items)

Output:
PS F:\Python\Practicals\7> python ex2.py
Repeated Numbers In numTuple Are : [42, 3]

Ex3: Print the number in words for Example: 1234 => One
Two Three Four
Practical No 7
# Print the number in words for Example: 1234 => One Two Three Four
numbers_in_words = {
0:"Zero",
1:"One",
2:"Two",
3:"Three",
4:"Four",
5:"Five",
6:"Six",
7:"Seven",
8:"Eight",
9:"Nine",
}
num = int(input("Enter A Number : "))
print("Number In Word Are : ",end="")
for i in range (len(str(num))):
lenOfNum = len(str(num))
digit_places = int("1"+"0"*(lenOfNum-1))
digit = num//digit_places
num%=digit_places
print(numbers_in_words[digit],end=" ")

Output:
PS F:\Python\Practicals\7> python ex3.py
Enter A Number : 1234
Number In Word Are : One Two Three Four

You might also like