Login using Social Account
Login using your credentials
An str object just like other objects in Python has 2 components- 1) data (string itself), and 2) methods associated with it i.e. built-in functions associated with any instance of the object.
str
a = "cloudxlab" dir(a)
The dir function lists the methods associated with the object. Try it in the notebook.
dir
To get information regarding any method, you can use the help function.
help
help(a.translate)
It provides simple documentation on the translate method of str object. You can also write as,
translate
help(str.translate)
We call a method just like the function call but here the variable or the instance of the object is followed by a . and then the method name. For eg,
.
print(a.upper())
It prints the string in uppercase as CLOUDXLAB. Now, if we do
CLOUDXLAB
print(a)
Can you tell the output
Further string methods' detailed descriptions you can find here.
Taking you to the next exercise in seconds...
Stay here Next Exercise
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
1 Getting Started - Setting up the environment
2 Introduction to Programming and Python
3 Why Programming?
4 A Quick Introduction
5 Who are programmers
6 Computer consists of
7 A code/program/software is
8 All the processing in a computer is done in the
9 All the information which is required for the execution of an instruction is stored in the
10 What do we use to interact with the computer
11 Main memory content is lost on reboot
12 Main memory is slower than secondary memory
13 Why do people use Python Programming language ?
14 Execution speed of Python is faster than C or C++
15 What all things you can do using Python ?
16 A program flow or program steps can be of either sequence, conditional or repeated ?
17 Which statement is used to take input in Python
18 Which statement is used show output in Python
19 Python Programming - Assigning value to a variable
20 Python as a Calculator
21 Python Programming - Integer Division
22 Order of Operations in Python
23 Advanced Operations in Python
24 Python Programming - Operator Precedence
25 Python - Variable Assignment
26 Variables in Python
27 Calculations with Variables
28 Hands-on on Python Variables
29 Types of Variables in Python
30 Python Programming - Types
31 Guess the Type
32 Operations with Other Types
33 Python - String Concatenation
34 Python - String Operations
35 Functions
36 Conditional Execution and Functions in Python
37 Python - Create Payment Calculator Function
38 Python Programming - Which of the following is not a comparison operator in...
39 Python Programming - Which of the following is used to depict a block...
40 Python Programming - Blank lines are ignored in Python ?...
41 Python Programming - Nested decision statements are possible in Python....
42 Python Programming - The correct syntax for conditional statements in Python is...
43 Python Programming - A try except block in Python is used for...
44 Python Programming - If the try block doesn't raise an exception than the...
45 Python Programming - input(), type(), len() are some of the built in functions...
46 Python Programming - In Python a function is some reusable code that takes...
47 Python Programming - max() and min() are default functions provided in Python for...
48 Python Programming - Executing the code print(max('Hello world')) will result in...
49 Python - Calculations with variables
50 Python - Guess The Type
51 Python - Type Conversion
52 Python Programming - Which of the following is not the default data type...
53 Python Programming - Which of the following in-built function in Python is used...
54 Python Programming - Function without any arguments
55 Python Programming - Just defining a function does not execute it, we need...
56 Python Programming - Once we define a function we can call it only...
57 Python Programming - Using in operator
58 Python Programming - We cannot define more than 1 parameter in Python....
59 Built-in Functions
60 Type Conversion Functions
61 Math Functions
62 Random Number Generation
63 Making your own functions
64 Flow of Execution
65 Parameters and Arguments
66 Types of Functions
67 Input from User
68 Comments
69 Boolean Expressions
70 Logical Operators
71 Conditional Execution
72 Visualize the Conditional
73 Catching Exceptions
74 Updating Variables
75 Basic Building Blocks of Python
76 Python Programming - A while loop runs untill the condition provided is true...
77 Python Programming - A break statement ends the current iteration and...
78 Python Programming - Infinite loops are not possible in Python...
79 Python Programming - The statement " for x in [1,2,3,4] : print(x) "...
80 Python Programming - The iteration variable iterates through the sequence...
81 Python Programming - In the statement " for i in [1, 2, 3]...
82 Python Programming - For which of the following application we can use loops?...
83 Python Programming - What are lists
84 Print Even Numbers up to n
85 Compute the Compound Interest
86 While loop
87 Break and Continue
88 For loop
89 Strings
90 String Slices
91 Immutability of Strings
92 in Operator
93 String methods
94 Parsing Strings
95 Format Operator
96 Lists
97 Lists v/s Strings
98 List Methods
99 Deleting Elements of List
100 Lists and Strings
101 Python - Understanding Files
102 Reading Files
103 Searching in Files
104 Writing Files
105 Python Dictionaries and Tuples
106 Python Programming - What are dictionaries
107 Python Programming - Dictionary Keys
108 Python Programming - Dictionary Key Value
109 Python Programming - Dictionary Initialisation
110 Python Programming - Get method in dictionaries
111 Python Programming - Iterating in dictionaries
112 Python Programming - Dictionary Methods
113 Python Programming - Immutable Tuples
114 Python Programming - Tuple Methods
115 Python Programming - Tuple comparison
116 Python Programming - Tuple efficiency
117 Python Programming - Sort and sorted
118 Dictionaries
119 Working with Dictionaries
120 Tuples
121 Working with Tuples
122 Comparison with Tuples
123 Tuple Assignment
124 Tuples and Dictionaries
125 Regular Expressions in Python
126 Network Programming in python
127 HTTP request using Socket
128 Python Classes and Objects
129 Python Programming - Objects
130 Python Programming - dir command on class
131 Python Programming - Class components
132 Python Programming - Purpose of constructors
133 Python Programming - Inheritance
134 Lambda Function and List Comprehension
Loading comments...