Skip to content

Commit 1c9e89f

Browse files
Module 3
1 parent 9ce55a4 commit 1c9e89f

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"+ ***str.strip()*** here to truncate all space lines\n",
8+
"+ ***str.find(istr)*** to return 0 based index of the matched substring, else -1\n",
9+
"+ ***str.title()*** to capitalize the first letter\n",
10+
"+ ***str.swapcase()*** to swap the cases of lower to upper and upper to lower"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 13,
16+
"metadata": {},
17+
"outputs": [
18+
{
19+
"data": {
20+
"text/plain": [
21+
"False"
22+
]
23+
},
24+
"execution_count": 13,
25+
"metadata": {},
26+
"output_type": "execute_result"
27+
}
28+
],
29+
"source": [
30+
"s='Gf'\n",
31+
"s.lower().find('gfg')==0 and s.lower().find('gfg',len(s)-3)==len(s)-3"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 8,
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"data": {
41+
"text/plain": [
42+
"8"
43+
]
44+
},
45+
"execution_count": 8,
46+
"metadata": {},
47+
"output_type": "execute_result"
48+
}
49+
],
50+
"source": [
51+
"s.lower().find('gfg',len(s)-3)"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": 9,
57+
"metadata": {},
58+
"outputs": [
59+
{
60+
"data": {
61+
"text/plain": [
62+
"8"
63+
]
64+
},
65+
"execution_count": 9,
66+
"metadata": {},
67+
"output_type": "execute_result"
68+
}
69+
],
70+
"source": [
71+
"len(s)-3"
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": 14,
77+
"metadata": {},
78+
"outputs": [
79+
{
80+
"data": {
81+
"text/plain": [
82+
"re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!#%*?&]{6,20}$',\n",
83+
"re.UNICODE)"
84+
]
85+
},
86+
"execution_count": 14,
87+
"metadata": {},
88+
"output_type": "execute_result"
89+
}
90+
],
91+
"source": [
92+
"import re\n",
93+
"reg = \"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!#%*?&]{6,20}$\"\n",
94+
" \n",
95+
"pat = re.compile(reg)\n",
96+
"\n",
97+
"pat"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {},
104+
"outputs": [],
105+
"source": []
106+
}
107+
],
108+
"metadata": {
109+
"kernelspec": {
110+
"display_name": "Python 3",
111+
"language": "python",
112+
"name": "python3"
113+
},
114+
"language_info": {
115+
"codemirror_mode": {
116+
"name": "ipython",
117+
"version": 3
118+
},
119+
"file_extension": ".py",
120+
"mimetype": "text/x-python",
121+
"name": "python",
122+
"nbconvert_exporter": "python",
123+
"pygments_lexer": "ipython3",
124+
"version": "3.7.5"
125+
}
126+
},
127+
"nbformat": 4,
128+
"nbformat_minor": 2
129+
}

0 commit comments

Comments
 (0)