Skip to content

Commit 61c46ee

Browse files
14/06/2023
1 parent 5de2b23 commit 61c46ee

File tree

2 files changed

+267
-0
lines changed

2 files changed

+267
-0
lines changed

Module1/Python string methods.ipynb

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"Python String methods"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 7,
14+
"metadata": {},
15+
"outputs": [
16+
{
17+
"name": "stdout",
18+
"output_type": "stream",
19+
"text": [
20+
"Shankar\n",
21+
"SHANKAR\n"
22+
]
23+
}
24+
],
25+
"source": [
26+
"s1=(\"shankar\")\n",
27+
"print(s1.capitalize()) # first letter only calpitalize\n",
28+
"print(s1.upper()) # all letters should capital\n",
29+
"\n"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 9,
35+
"metadata": {},
36+
"outputs": [
37+
{
38+
"name": "stdout",
39+
"output_type": "stream",
40+
"text": [
41+
"shankar\n"
42+
]
43+
}
44+
],
45+
"source": [
46+
"s1=(\"SHANKAR\")\n",
47+
"print(s1.lower()) # all leter should lower letter\n"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": 14,
53+
"metadata": {},
54+
"outputs": [
55+
{
56+
"name": "stdout",
57+
"output_type": "stream",
58+
"text": [
59+
"**Shankar**\n"
60+
]
61+
}
62+
],
63+
"source": [
64+
"s1=(\"Shankar\")\n",
65+
"print(s1.center(11,'*')) # head line writen using str *"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": 18,
71+
"metadata": {},
72+
"outputs": [
73+
{
74+
"name": "stdout",
75+
"output_type": "stream",
76+
"text": [
77+
"5\n"
78+
]
79+
}
80+
],
81+
"source": [
82+
"s3=(\" WELLCOME HELLO WORLD\")\n",
83+
"print(s3.count(\"L\")) # count the Selecting letters "
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": 23,
89+
"metadata": {},
90+
"outputs": [
91+
{
92+
"name": "stdout",
93+
"output_type": "stream",
94+
"text": [
95+
"10\n"
96+
]
97+
}
98+
],
99+
"source": [
100+
"s3=(\" WELLCOME HELLO WORLD\")\n",
101+
"print(s3.index('H')) # Find the index number of letter"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": 48,
107+
"metadata": {},
108+
"outputs": [
109+
{
110+
"name": "stdout",
111+
"output_type": "stream",
112+
"text": [
113+
"-1\n"
114+
]
115+
}
116+
],
117+
"source": [
118+
"s3=(\"HELLOWORLD\")\n",
119+
"print(s3.find('LR'))"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 43,
125+
"metadata": {},
126+
"outputs": [
127+
{
128+
"name": "stdout",
129+
"output_type": "stream",
130+
"text": [
131+
"14-06-2023\n"
132+
]
133+
}
134+
],
135+
"source": [
136+
"str=(\"14/06/2023\")\n",
137+
"print(str.replace('/','-')) # replace the sign ,Numbers ,and letters"
138+
]
139+
},
140+
{
141+
"cell_type": "code",
142+
"execution_count": 49,
143+
"metadata": {},
144+
"outputs": [
145+
{
146+
"name": "stdout",
147+
"output_type": "stream",
148+
"text": [
149+
"['14', '06', '2023']\n"
150+
]
151+
}
152+
],
153+
"source": [
154+
"str=(\"14/06/2023\")\n",
155+
"print(str.split('/')) # split the numbers "
156+
]
157+
},
158+
{
159+
"cell_type": "code",
160+
"execution_count": 70,
161+
"metadata": {},
162+
"outputs": [
163+
{
164+
"name": "stdout",
165+
"output_type": "stream",
166+
"text": [
167+
"True\n",
168+
"False\n"
169+
]
170+
}
171+
],
172+
"source": [
173+
"str1=('12345')\n",
174+
"print(str1.isnumeric()) # print only number \n",
175+
"str1=('avdf')\n",
176+
"print(str1.isnumeric())"
177+
]
178+
},
179+
{
180+
"cell_type": "code",
181+
"execution_count": 69,
182+
"metadata": {},
183+
"outputs": [
184+
{
185+
"name": "stdout",
186+
"output_type": "stream",
187+
"text": [
188+
"True\n",
189+
"False\n"
190+
]
191+
}
192+
],
193+
"source": [
194+
"str1=('1a')\n",
195+
"print(str1.isalnum()) # print only alphabet and number\n",
196+
"str1=('1./')\n",
197+
"print(str1.isalnum())"
198+
]
199+
},
200+
{
201+
"cell_type": "code",
202+
"execution_count": 68,
203+
"metadata": {},
204+
"outputs": [
205+
{
206+
"name": "stdout",
207+
"output_type": "stream",
208+
"text": [
209+
"True\n",
210+
"False\n"
211+
]
212+
}
213+
],
214+
"source": [
215+
"str1=('SHANKAR')\n",
216+
"print(str1.isupper())\n",
217+
"\n",
218+
"str1=('SHANKAr')\n",
219+
"print(str1.isupper())"
220+
]
221+
},
222+
{
223+
"cell_type": "code",
224+
"execution_count": 72,
225+
"metadata": {},
226+
"outputs": [
227+
{
228+
"name": "stdout",
229+
"output_type": "stream",
230+
"text": [
231+
"False\n",
232+
"True\n"
233+
]
234+
}
235+
],
236+
"source": [
237+
"str1=('Shankar')\n",
238+
"print(str1.islower())\n",
239+
"\n",
240+
"str1=('shankar')\n",
241+
"print(str1.islower())"
242+
]
243+
}
244+
],
245+
"metadata": {
246+
"kernelspec": {
247+
"display_name": "Python 3",
248+
"language": "python",
249+
"name": "python3"
250+
},
251+
"language_info": {
252+
"codemirror_mode": {
253+
"name": "ipython",
254+
"version": 3
255+
},
256+
"file_extension": ".py",
257+
"mimetype": "text/x-python",
258+
"name": "python",
259+
"nbconvert_exporter": "python",
260+
"pygments_lexer": "ipython3",
261+
"version": "3.11.3"
262+
},
263+
"orig_nbformat": 4
264+
},
265+
"nbformat": 4,
266+
"nbformat_minor": 2
267+
}
File renamed without changes.

0 commit comments

Comments
 (0)