<jupyter_start><jupyter_text>Python : List Manupulation   1. List Indexing and Slicing<jupyter_code>months = ['Janauary', 'February', 'March', 'April', 'May', 'June', 'July',
          'August', 'September', 'October', 'November', 'December']

print(months)
print(len(months))
print(months[4])
print(months[1:5])
print(months[:4])
print(months[4:])
print(months[-1])
print(months[5:-1])
print(" I am a " + months[2].lower() + " born")<jupyter_output>I am a march born<jupyter_text>a. Changing Values in a List with Indexes<jupyter_code>anim = ['cat', 'bat', 'rat', 'elephant']

anim[1] = 'dog'

print(anim)
anim[3] = anim[1]

print(anim)<jupyter_output>['cat', 'dog', 'rat', 'dog']<jupyter_text>b. List containing other lists<jupyter_code>spam = [['cat', 'bat'], [10, 20, 30, 40, 50]]
print(spam[0])
print(spam[0][1])
print(spam[1][4])
print(spam[1][:2])<jupyter_output>[10, 20]<jupyter_text>2. List Sorting<jupyter_code>colours = ['red', 'green', 'yellow', 'orange', 'voilet', 'black', 'white', 'blue', 'indigo', 'brown', 'purple']

temperature = [34, 26.8, 39, 48, 44, 18, 23, 36.8, 47]

months = ['Janauary', 'February', 'March', 'April', 'May', 'June', 'July', 
          'August', 'September', 'October', 'November', 'December']<jupyter_output><empty_output><jupyter_text>``sort()``<jupyter_code># Sorting list permanently using sort()

colours.sort()
print(colours)
temperature.sort()
print(temperature)
# Sort list in reverse

colours.sort(reverse=True)
print(colours)<jupyter_output>['yellow', 'white', 'voilet', 'red', 'purple', 'orange', 'indigo', 'green', 'brown', 'blue', 'black']<jupyter_text>``reverse()``<jupyter_code># Reverse order of data in list

months.reverse()
print(months)<jupyter_output>['December', 'November', 'October', 'September', 'August', 'July', 'June', 'May', 'April', 'March', 'February', 'Janauary']<jupyter_text>3. Working with the elements to the list  a. Adding the elements at the end of the list<jupyter_code>cars = ["Honda", "Maruthi", "Volvo"]

cars.append("benz")

print(cars)
# Creating a list of square no of 1 to 10
squr = []
for value in range(1,11): 
    squr.append(value**3)
print(squr)<jupyter_output>[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]<jupyter_text>b. Inserting the elements to the list<jupyter_code>cars = ["Honda", "Maruthi", "Volvo"]

cars.insert(2, "Mahindra")

print(cars)<jupyter_output>['Honda', 'Maruthi', 'Mahindra', 'Volvo']<jupyter_text>c. Removing the elements from the list  ``del()``<jupyter_code>cars = ["Honda", "Maruthi", "Volvo", "pagani", "Tata"]

del cars[:2]

print(cars)<jupyter_output>['Volvo', 'pagani', 'Tata']<jupyter_text>d. Removing the elements from the list  ``pop()``<jupyter_code>cars = ["Honda", "Maruthi", "Volvo", "pagani", "Tata"]

luxury_car = cars.pop(3)

print(cars)

print(luxury_car)<jupyter_output>['Honda', 'Maruthi', 'Volvo', 'Tata']
pagani<jupyter_text>e. Removing an Item by Value ``remove()``<jupyter_code>cars = ["Honda", "Maruthi", "Volvo", "pagani", "Tata"]

cars.remove("pagani")

print(cars)<jupyter_output>['Honda', 'Maruthi', 'Volvo', 'Tata']<jupyter_text>f. Using ``range()``  function to create array<jupyter_code># Using range() to creat list
numbers = (list(range(0,21)))
print(numbers)

even_numbers = (list(range(2,21,3)))
print(even_numbers)<jupyter_output>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[2, 5, 8, 11, 14, 17, 20]<jupyter_text>4. Simple statistics with list<jupyter_code>temperature = [34, 26.8, 39, 48, 44, 18, 23, 36.8, 28, 16, 12, 17]

print(min(temperature))
print(max(temperature))
print(sum(temperature))<jupyter_output>12
48
342.6
{'fraction_non_alphanumeric': 0.20832177531206658, 'fraction_numerical': 0.04882108183079057, 'mean_word_length': 7.121621621621622, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '537561', 'license': 'MIT', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1435, 'n_words': 335, 'path': '03.1. Python_List_Manipulation.ipynb', 'repo_name': 'demaria11/python-in-a-notebook', 'size': '3605'}