Remove duplicates from a list and create a tuple and find the minimum and maximum number

Python Python List (Article) Python List (Program)

147

Given Input:

sample_list = [87, 45, 41, 65, 94, 41, 99, 94]

Expected Output:

unique items [87, 45, 41, 65, 99]
tuple (87, 45, 41, 65, 99)
min: 41
max: 99

Program:

<span class="pln">sample_list </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="lit">87</span><span class="pun">,</span><span class="pln"> </span><span class="lit">52</span><span class="pun">,</span><span class="pln"> </span><span class="lit">44</span><span class="pun">,</span><span class="pln"> </span><span class="lit">53</span><span class="pun">,</span><span class="pln"> </span><span class="lit">54</span><span class="pun">,</span><span class="pln"> </span><span class="lit">87</span><span class="pun">,</span><span class="pln"> </span><span class="lit">52</span><span class="pun">,</span><span class="pln"> </span><span class="lit">53</span><span class="pun">]</span><span class="pln">

</span><span class="kwd">print</span><span class="pun">(</span><span class="str">"Original list"</span><span class="pun">,</span><span class="pln"> sample_list</span><span class="pun">)</span><span class="pln">

sample_list </span><span class="pun">=</span><span class="pln"> list</span><span class="pun">(</span><span class="kwd">set</span><span class="pun">(</span><span class="pln">sample_list</span><span class="pun">))</span><span class="pln">
</span><span class="kwd">print</span><span class="pun">(</span><span class="str">"unique list"</span><span class="pun">,</span><span class="pln"> sample_list</span><span class="pun">)</span><span class="pln">

t </span><span class="pun">=</span><span class="pln"> tuple</span><span class="pun">(</span><span class="pln">sample_list</span><span class="pun">)</span><span class="pln">
</span><span class="kwd">print</span><span class="pun">(</span><span class="str">"tuple "</span><span class="pun">,</span><span class="pln"> t</span><span class="pun">)</span><span class="pln">

</span><span class="kwd">print</span><span class="pun">(</span><span class="str">"Minimum number is: "</span><span class="pun">,</span><span class="pln"> min</span><span class="pun">(</span><span class="pln">t</span><span class="pun">))</span><span class="pln">
</span><span class="kwd">print</span><span class="pun">(</span><span class="str">"Maximum number is: "</span><span class="pun">,</span><span class="pln"> max</span><span class="pun">(</span><span class="pln">t</span><span class="pun">))</span>

Output:

Original list [87, 52, 44, 53, 54, 87, 52, 53]
unique list [44, 52, 53, 54, 87]
tuple  (44, 52, 53, 54, 87)
Minimum number is:  44
Maximum number is:  87

This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.