<jupyter_start><jupyter_text>List<jupyter_code>L =[1,2,3,4,5,6,121,43]
print(L)<jupyter_output>[1, 2, 3, 4, 5, 6, 121, 43]<jupyter_text>.Indexing of list<jupyter_code>L[0],L[3],L[-1],L[-3]<jupyter_output><empty_output><jupyter_text>* For the length of list<jupyter_code>len(L)<jupyter_output><empty_output><jupyter_text>* To add the element from last<jupyter_code>L.append(22)
L<jupyter_output><empty_output><jupyter_text>To find sum of the elements<jupyter_code>sum(L)<jupyter_output><empty_output><jupyter_text>To find maximum and minimum of the list<jupyter_code>max(L),min(L)<jupyter_output><empty_output><jupyter_text>? To create a list of heterogeneous element types<jupyter_code>L =[1,2,3,4,5.0,"Banana",True,False]
type(L[2]),type(L[5])
type(L[4]) ,type(L[-1])<jupyter_output><empty_output><jupyter_text>To create a list of list<jupyter_code>L =[[1,2,3],[4,5,6],[7,8,9]]<jupyter_output><empty_output><jupyter_text>To find list inside a list<jupyter_code>L[0][2]<jupyter_output><empty_output><jupyter_text>.To add two lists in case of set<jupyter_code>L1 = [1,2,3] ; L2 = [2,4,6]
L1+L2, set (L1+L2)<jupyter_output><empty_output><jupyter_text>To add element fromend of the list<jupyter_code>L = [1,2,3,4,9,0,6]
L.append(45)
L<jupyter_output><empty_output><jupyter_text>To insert (29) on first index<jupyter_code>L = [1,2,3,4,9,0,6]
L.insert(1,29)
L<jupyter_output><empty_output><jupyter_text>To remove an element (2)<jupyter_code>L = [1,2,3,4,9,0,6]
L.remove(2)
L<jupyter_output><empty_output><jupyter_text>To remove the element from specific index<jupyter_code>L = [1,2,3,4,9,0,6]
L.pop(-2)
L<jupyter_output><empty_output><jupyter_text>To sort the list<jupyter_code>L = [1,2,3,4,9,0,6]
L.sort()
L<jupyter_output><empty_output><jupyter_text>To reverse the list<jupyter_code>L = [1,2,3,4,9,0,6]
L.reverse()
L<jupyter_output><empty_output><jupyter_text>List comprehension<jupyter_code>L = [x for x in range(50)]
print(L)
L = [x for x in range(50) if x%2==0]
print(L)
import random as rn
rn.randint(0,50)
import random as rn
R = [rn.randint(0,50) for k in range (100)]
print(R)
R = [rn.choice(['A' ,'T','G','C']) for i in range (200)]
print(R)<jupyter_output>['A', 'C', 'C', 'G', 'T', 'A', 'G', 'C', 'A', 'G', 'G', 'G', 'C', 'A', 'G', 'G', 'G', 'T', 'C', 'C', 'A', 'A', 'T', 'G', 'T', 'T', 'C', 'A', 'A', 'G', 'A', 'T', 'T', 'A', 'C', 'C', 'C', 'G', 'G', 'G', 'T', 'T', 'T', 'G', 'C', 'C', 'C', 'C', 'G', 'G', 'T', 'T', 'G', 'C', 'C', 'C', 'A', 'G', 'T', 'C', 'T', 'C', 'A', 'C', 'C', 'C', 'C', 'A', 'A', 'C', 'G', 'C', 'G', 'A', 'T', 'A', 'C', 'A', 'T', 'G', 'C', 'G', 'G', 'C', 'A', 'T', 'G', 'C', 'A', 'C', 'A', 'G', 'G', 'C', 'T', 'A', 'A', 'A', 'G', 'C', 'C', 'A', 'T', 'A', 'C', 'T', 'T', 'T', 'A', 'C', 'A', 'C', 'A', 'C', 'G', 'A', 'A', 'C', 'C', 'A', 'G', 'A', 'T', 'A', 'T', 'G', 'A', 'A', 'C', 'T', 'A', 'T', 'C', 'C', 'A', 'T', 'A', 'T', 'A', 'C', 'G', 'A', 'T', 'G', 'G', 'G', 'A', 'C', 'G', 'G', 'A', 'A', 'T', 'A', 'G', 'C', 'C', 'T', 'A', 'G', 'G', 'C', 'T', 'C', 'G', 'C', 'G', 'C', 'G', 'T', 'A', 'G', 'T', 'C', 'A', 'A', 'T', 'T', 'G', 'A', 'A', 'G', 'T', 'G', 'A', 'T', 'C', 'A', 'G', 'G', 'G', 'T', 'T', 'A', 'T', 'G', 'C', 'G', 'C', 'A'][...]<jupyter_text>Tuples To define a tuple from scratch<jupyter_code>t =(2,3,4,6)<jupyter_output><empty_output><jupyter_text>Find type<jupyter_code>type(t)
t[2]
L =[(1,2),(2,3),(3,4)]
L[0][0]<jupyter_output><empty_output><jupyter_text>Create a list of tuple<jupyter_code>L =[(1,2),("a","b"),(True,False)]
L<jupyter_output><empty_output><jupyter_text>Dictionary  Initiate dictionary<jupyter_code>D = dict()
DD = {}<jupyter_output><empty_output><jupyter_text>Create a dictionary from scratch<jupyter_code>D ={"fruits": 'banana',
     "Vegetable": 'radish',
     "rice": '3.00',
     "water": '100'}<jupyter_output><empty_output><jupyter_text>What are keys?<jupyter_code>D.keys()
D.values()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2904639175257732, 'fraction_numerical': 0.03917525773195876, 'mean_word_length': 7.624444444444444, 'pattern_counts': {'":': 4, '<': 91, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '488732', 'license': 'MIT', 'n_tokens_mistral': 1970, 'n_tokens_neox': 1925, 'n_words': 396, 'path': 'List tuple dictionary.ipynb', 'repo_name': 'Rabibryan/List-Tuple-Dictionary', 'size': '3880'}