Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 8 - More on Strings and Special Methods - Section 8.2 - The str Class - Check Point - MyProgrammingLab - Page 253: 8.4

Answer

a) isEqual = False b) isEqual = True c) b = False d) b = False e) x = 9 (Len also counts White space characters) f) x = " " (Index 0 is white space character) g) s3 = " Welcome welcome " (2 White space characters between s1,s2) h) s3 = "Welcome " (0 index white space character is removed) i) s3 = "Welc" (0 index white space character and only till 4 index is taken as 5 index is exclusive j) s3 = " welcome " k) s3 = " WELCOME " l) s3 = "Welcome" (Removes White space characters in the beginning and ending) m) s3 = " WElcomE " (Replaces all occurences of e with E) n) x = 1 (It means e is present in s1 at index 1) o) x = -1 (It means abc is not present in s1)

Work Step by Step

a) isEqual = (s1 == s2) b) isEqual = (s1.lower() == s2.lower()) c) b = s1.startswith("AAA") d) b = s1.endswith("AAA") e) x = len(s1) f) x = s1[0] g) s3 = s1 + s2 h) s3 = s1[1:] i) s3 = s1[1:5] j) s3 = s1.lower() k) s3 = s1.upper() l) s3 = s1.strip() m) s3 = s1.replace("e", "E") n) x = s1.find("e") o) x = s1.rfind("abc")
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.