Exercise: Dir and Help  Learn about the methods Python provides for strings. To see what methods Python provides for a datatype, use the dir and help commands:  >>> s = 'abc'   >>> dir(s)  ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__',  '__ge__', '__getattribute__', '__getitem__', '__getnewargs__',  '__getslice__', '__gt__', '__hash__', '__init__','__le__', '__len__',  '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__',  '__reduce_ex__','__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__',  'capitalize', 'center', 'count', 'decode', 'encode', 'endswith',  'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower',  'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',  'replace', 'rfind','rindex', 'rjust', 'rsplit', 'rstrip', 'split',  'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate',  'upper', 'zfill']  >>> help(s.find)  Help on built-in function find:  find(...) method of builtins.str instance      S.find(sub[, start[, end]]) -> int  Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].  Optional arguments start and end are interpreted as in slice notation.  Return -1 on failure.  >> s.find('b')  Try out some of the string functions listed in dir (ignore those with underscores '_' around the method name).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Exercise: Dir and Help 

Learn about the methods Python provides for strings. To see what methods Python provides for a datatype, use the dir and help commands: 

>>> s = 'abc'  

>>> dir(s) 

['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__',  '__ge__', '__getattribute__', '__getitem__', '__getnewargs__',  '__getslice__', '__gt__', '__hash__', '__init__','__le__', '__len__',  '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', 

'__reduce_ex__','__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__',  'capitalize', 'center', 'count', 'decode', 'encode', 'endswith',  'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower',  'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',  'replace', 'rfind','rindex', 'rjust', 'rsplit', 'rstrip', 'split',  'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate',  'upper', 'zfill'] 

>>> help(s.find) 

Help on built-in function find: 

find(...) method of builtins.str instance 

    S.find(sub[, start[, end]]) -> int 

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].  Optional arguments start and end are interpreted as in slice notation. 

Return -1 on failure. 

>> s.find('b') 

  1. Try out some of the string functions listed in dir (ignore those with underscores '_' around the method name).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY