<jupyter_start><jupyter_text>Practice Exercise - 02 - Solution  Question 1:Print the item 'Orange' from the list of fruits given below.fruits = ['Apple', 'Grapes', 'Orange', 'Pineapple', 'Watermelon'] Expected Output:Orange<jupyter_code>fruits = ['Apple', 'Grapes', 'Orange', 'Pineapple', 'Watermelon']

print(fruits[2])<jupyter_output>Orange<jupyter_text>Question 2:We have a list of fruits and a string given below. Since the string contains fruit, add that string to the given list and print that new list.fruit_list = ['Apple', 'Grapes', 'Orange', 'Pineapple', 'Watermelon']fruit_string = 'Mango' Expected Output:['Apple', 'Grapes', 'Orange', 'Pineapple', 'Watermelon', 'Mango']<jupyter_code>fruit_list = ['Apple', 'Grapes', 'Orange', 'Pineapple', 'Watermelon']
fruit_string = 'Mango'

print(fruit_list + [fruit_string])<jupyter_output>['Apple', 'Grapes', 'Orange', 'Pineapple', 'Watermelon', 'Mango']<jupyter_text>Question 3:There is a list given below which contains the name of cities. Repeat this list of cities three times, and print the old list and the new list.cityList = ['London', 'New York', 'Delhi'] Expected Output:Old City List: ['London', 'New York', 'Delhi']New City List: ['London', 'New York', 'Delhi', 'London', 'New York', 'Delhi', 'London', 'New York', 'Delhi']<jupyter_code>cityList = ['London', 'New York', 'Delhi']

repeatedList = cityList * 3
print("Old City List: " + str(cityList))
print("New City List: " + str(repeatedList))<jupyter_output>Old City List: ['London', 'New York', 'Delhi']
New City List: ['London', 'New York', 'Delhi', 'London', 'New York', 'Delhi', 'London', 'New York', 'Delhi']<jupyter_text>Question 4:Check if the city 'Delhi' is present in the list of cities given below.cityList = ['London', 'New York', 'Delhi', 'Mumbai', 'Paris'] Expected Output:True<jupyter_code>cityList = ['London', 'New York', 'Delhi', 'Mumbai', 'Paris']

print('Delhi' in cityList)<jupyter_output>True<jupyter_text>Question 5:Reverse the string given below.name = 'Learning Journal' Expected Output:'lanruoJ gninraeL'<jupyter_code>name = 'Learning Journal'

name[::-1]<jupyter_output><empty_output><jupyter_text>Question 6:There is a string object given below. Print the word 'sunny' from string 'msg.'msg = 'A bright sunny day' Expected Solution:'sunny'<jupyter_code>msg = 'A bright sunny day'

msg[9:14]<jupyter_output><empty_output><jupyter_text>Question 7:Check if the cities 'New York' and 'Delhi' are present in the list of cities given below.cityList = ['London', 'New York', 'Delhi', 'Mumbai', 'Paris'] Expected Output:TrueTrue<jupyter_code>cityList = ['London', 'New York', 'Delhi', 'Mumbai', 'Paris']

print('New York' in cityList)
print('Delhi' in cityList)<jupyter_output>True
True<jupyter_text>Explanation:If your try searching for 'New York' and 'Delhi' in a single statement like this.print(['New York', 'Delhi'] in cityList)You will get the output as false. This is because subsequence containment is only applicable to str objects.  Question 8:Using the slicing operation, remove the whitespaces between the letters and print the string once again.name = '<NAME>' Expected Output:'Python'<jupyter_code>name = '<NAME>'

name[::2]<jupyter_output><empty_output><jupyter_text>Question 9:Print the index of the letter 'h' from the string given below.name = 'Python' Expected Output:3<jupyter_code>name = 'Python'

print(name.index('h'))<jupyter_output>3<jupyter_text>Question 10:Print the odd indexed elements from the list of colors given below.myList = ['Red', 'Blue', 'Orange', 'White', 'Black', 'Yellow'] Expected Output:['Blue', 'White', 'Yellow']<jupyter_code>myList = ['Red', 'Blue', 'Orange', 'White', 'Black', 'Yellow']

myList[1::2]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15274784482758622, 'fraction_numerical': 0.00646551724137931, 'mean_word_length': 7.287946428571429, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '309490', 'license': 'MIT', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1241, 'n_words': 385, 'path': 'practice-exercise-02-solution.ipynb', 'repo_name': 'LearningJournal/Python-Foundation-Course', 'size': '3722'}