# -*- coding: utf-8 -*-
"""ln 9 Book Back Exercises_Lists.ipynb
Automatically generated by Colaboratory.
Original file is located at
    https://colab.research.google.com/drive/1GbjT7w8lZFxe8TMCULac1mknvz7Mgq1S
#About this notebook
Notebook made by: Dhananjay M.R
Subject: Computer Science - Grade 11 CBSE
Language: - Python
Topic: Book Back Exercise Questions of the lesson - Lists
Execution mode: Script Mode

Note: Theory based questions are not available in this notebook.

Note: This is a compilation of the entire book. 
If you run this program directly, you may encouter with error.
Therefore it is recommended to cut the program (modify) and run it part by part

Refering the original file at Colaboratory is recommended for better understanding the codes
Original file is located at
    https://colab.research.google.com/drive/1GbjT7w8lZFxe8TMCULac1mknvz7Mgq1S
    

#Qn No.1 What will be the output of the following statements?
"""

# Part i
print('Solution for the part i of the question: ')
list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
print('')
# End of part i :)

# Part ii
print('Solution for the part ii of the question: ')
list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)
print('')
# End of part ii :)

# Part iii
print('Solution for the part iii of the question: ')
list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]
print(list1)
print('')
# End of part iii :)

# Part iv
print('Solution for the part iv of the question: ')
list1 = [1,2,3,4,5]
list1[len(list1)-1]
# End of part iv :)

"""#Qn No.2 What will be the elements of myList after the following two operations:
 myList = [10,20,30,40] 
 
 i. myList.append([50,60]) 
 
 ii. myList.extend([80,90])
"""

myList = [10,20,30,40]
myList.append([50,60])
myList.extend([80,90])
print(myList)

"""#Qn No.3 What will be the output of the following code segment: 
 myList = [1,2,3,4,5,6,7,8,9,10]
 
 for i in range(0,len(myList)):
 
  if i%2 == 0:

print(myList[i])
"""

myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0,len(myList)):
  if i%2 ==0:
    print(myList[i])

"""#Qn No.4 What will be the output of the following code segment:"""

# Part i
print('Solution for the part i of the question: ')
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)
print('')
# End of part i :)

# Part ii
print('Solution for the part ii of the question: ')
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)
print('')
# End of part ii :)

# Part iii
print('Solution for the part iii of the question: ')
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)
# End of part iii :)

"""#Qn No.7 Write Python statements to retrieve the following information from the list.
The record of a student (Name, Roll No., Marks in five subjects and percentage of    marks) is stored in the following list: 

stRecord = ['Raman','A-36',[56,98,99,72,69],78.8] 

Write Python statements to retrieve the following information from the list stRecord. 

a) Percentage of the student 

b) Marks in the fifth subject 

c) Maximum marks of the student 

d) Roll no. of the student 

e) Change the name of the student from ‘Raman’ to ‘Raghav’
"""

stRecord = ['Raman','A-36',[56,98,99,72,69],78.8]
print('The percentage acquired by the student is:', stRecord[3])
print('The mark scored by the student in the 5th subject is:', stRecord[2][4])
print('The highest mark obtained by the student is', max(stRecord[2]))
print('The roll no of the student is', stRecord[1])
stRecord[0] = 'Raghav'
print(stRecord)
