# -*- coding: utf-8 -*-
"""ln 8 Book Back Exercises_Strings.ipynb
Automatically generated by Colaboratory.
Original file is located at
    https://colab.research.google.com/drive/1irVdWdq_3ZA8bMlRS4IYTPZSpOxre9G4
#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 - Strings
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 of the codes
Original file is located at
    https://colab.research.google.com/drive/1irVdWdq_3ZA8bMlRS4IYTPZSpOxre9G4
    

#Qn No.1 What will be the output for the following string operations:
Consider the following string mySubject:        

mySubject = "Computer Science"
"""

mySubject = "Computer Science"
# The above string is a global variable which will be used throughout the notebook

# Part i
print('Solution for the part i of the question: ')
print(mySubject[0:len(mySubject)])
print('')
# End of part i :)

# Part ii
print('Solution for the part ii of the question: ')
print(mySubject[-7:-1])
print('')
# End of part ii :)

# Part iii
print('Solution for the part iii of the question: ')
print(mySubject[::2])
print('')
# End of part iii :)

# Part iv
print('Solution for the part iv of the question: ')
print(mySubject[len(mySubject)-1])
print('')
# End of part iv :)

# Part v
print('Solution for the part v of the question: ')
print(2*mySubject)
print('')
# End of part v :)

# Part vi
print('Solution for the part vi of the question: ')
print(mySubject[::-2])
print('')
# End of part vi :)

# Part vii
print('Solution for the part vii of the question: ')
print(mySubject[:3] + mySubject[3:])
print('')
# End of part vii :)

# Part viii
print('Solution for the part viii of the question: ')
print(mySubject.swapcase())
print('')
# End of part viii :)

# Part ix
print('Solution for the part ix of the question: ')
print(mySubject.startswith('Comp'))
print('')
# End of part ix :)

# Part x
print('Solution for the part x of the question: ')
print(mySubject.isalpha())
print('')
# End of part x :)

"""#Qn No.2 What will be the output for the following string operations:
Consider the following string myAddress:             

myAddress = "WZ-1,New Ganga Nagar,New Delhi"
"""

myAddress = "WZ-1,New Ganga Nagar,New Delhi"
# The above string is a global variable which will be used throughout the notebook

# Part i
print('Solution for the part i of the question: ')
print(myAddress.lower())
print('')
# End of part i :)

# Part ii
print('Solution for the part ii of the question: ')
print(myAddress.upper())
print('')
# End of part ii :)

# Part iii
print('Solution for the part iii of the question: ')
print(myAddress.count('New'))
print('')
# End of part iii :)

# Part iv
print('Solution for the part iv of the question: ')
print(myAddress.find('New'))
print('')
# End of part iv :)

# Part v
print('Solution for the part v of the question: ')
print(myAddress.rfind('New'))
print('')
# End of part v :)

# Part vi
print('Solution for the part vi of the question: ')
print(myAddress.split(','))
print('')
# End of part vi :)

# Part vii
print('Solution for the part vii of the question: ')
print(myAddress.split(' '))
print('')
# End of part vii :)

# Part viii
print('Solution for the part viii of the question: ')
print(myAddress.replace('New','Old'))
print('')
# End of part viii :)

# Part ix
print('Solution for the part ix of the question: ')
print(myAddress.partition(','))
print('')
# End of part ix :)

# Part x
print('Solution for the part x of the question: ')
print(myAddress.index('Agra'))
print('')
# End of part x :)
# Note: part x, ends up with an error
