-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass 2 (INDEXING &DATA CONVERSION).py
221 lines (108 loc) · 2.39 KB
/
class 2 (INDEXING &DATA CONVERSION).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#indexing postion
0 1 2 3 4 5
P Y T H O N
-6 -5 -4 -3 -2 -1
# In[3]:
#index position
a="Sachin Tendulkar";
print(a[5]);
# In[5]:
#characters between the index
print(a[3:10]);
# In[7]:
#index postion in reverse order
print(a[-1]);
# In[11]:
#index all the characters
print(a[:])
print(a[::])
# In[13]:
#index with start: end:intervals postions
print(a[::3])
# In[27]:
#reversing the string
# by only changing the interval from reverse we can reverse the entire string
print(a[::-1]);
print(a[::-3]);
# In[29]:
#index postion of the variable in the array
print(a.index("S"));
# In[31]:
#a postion after interval
print(a.index("a",3))
# In[33]:
#a position between start aand end value
print(a.index("a",0,3));
# In[35]:
#finding the postion from reverse of the string
print(a.rindex('a'));
# In[37]:
# find the postion of the element
print(a.find("a"));
# In[39]:
#reverse finding the position of the element
print(a.rfind("a"));
# In[41]:
#index postion of the element not in the string
print(a.index("z"))
# In[43]:
#finding the postion of the element not in the string returns -1
print(a.find("z"));
# In[45]:
#
print(a.find("z"))
# In[47]:
#reverse index of the element not in the string
print(a.rindex("z"))
# In[48]:
#find the element not in the string returns -1
print(a.rfind("z"))
# In[50]:
#count the times of element repeated in the string
print(a.count("a"))
# In[52]:
# spliting the mentioned element from the string
print(a.split("a"))
# In[56]:
#replacing the element mentioned
print(a.replace("a","$"))
# In[59]:
#splitting the element in the mentioned time
print(a.split("a",1))
# In[61]:
#replacing the element in the mentioned time
print(a.replace("a","$",1))
# In[63]:
a="Welcome to the Class"
#capitalize as a tile
print(a.title())
#capitializing only the first element
print(a.capitalize())
# In[72]:
a=123
#type of the data type
print(type(a))
#verfying the data type
print(isinstance(a,int))
# In[75]:
a="123"
#data type
print(type(a))
#checking the data type
print(isinstance(a,int))
#checking is digit or not
print(a.isdigit())
# In[85]:
#converting the data type (tyepcasting)
print(int(a))
a=123
#converting the floating value
print(float(a))
#converting into octal decimal
print(oct(a))
#converting into the hexadecimal
print(hex(a))
# In[ ]: