Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c01f21

Browse files
Add files via upload
1 parent 7d8fa0c commit 9c01f21

File tree

2 files changed

+444
-0
lines changed

2 files changed

+444
-0
lines changed

‎Day_14 _(12May2019).ipynb‎

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# PROBLEM SOLVING AND PROGRMMING\n",
8+
"### DAY-14\n",
9+
"### DATE:12May20019"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": []
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
"source": [
23+
"### Problem 1:\n",
24+
"### Statement \n",
25+
"Define a function if a given year is a leap year\n",
26+
"### Test Cases:\n",
27+
"* 2000-->True\n",
28+
"* 1900-->False\n",
29+
"* 2012-->True\n",
30+
"* 2020-->True\n",
31+
"* 0200-->False"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 2,
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"data": {
41+
"text/plain": [
42+
"True"
43+
]
44+
},
45+
"execution_count": 2,
46+
"metadata": {},
47+
"output_type": "execute_result"
48+
}
49+
],
50+
"source": [
51+
"def CheckLeap(y):\n",
52+
" if y%4==0 or y%100==0 and y%400 :\n",
53+
" return True\n",
54+
" return False\n",
55+
"CheckLeap(2000)"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": null,
61+
"metadata": {},
62+
"outputs": [],
63+
"source": [
64+
" "
65+
]
66+
},
67+
{
68+
"cell_type": "markdown",
69+
"metadata": {},
70+
"source": [
71+
"## Day_14 Problems:"
72+
]
73+
},
74+
{
75+
"cell_type": "markdown",
76+
"metadata": {},
77+
"source": [
78+
"## Problem 3:\n",
79+
"### Statement :\n",
80+
"You are given n words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. \n",
81+
"First line of input contains the total number of words n. Next n lines contain words that need to processed.\n",
82+
"\n",
83+
"First line of the output should contain the total number distinct words. Second line of output must contain the frequency of words the same order of their appearance as in the input\n",
84+
"### Test Cases:\n",
85+
"Sample Input : 6\n",
86+
"\n",
87+
"abcd\n",
88+
"\n",
89+
"ijkl\n",
90+
"\n",
91+
"abcd\n",
92+
"\n",
93+
"pqrs\n",
94+
"\n",
95+
"abcd\n",
96+
"\n",
97+
"ijkl\n",
98+
"\n",
99+
"Sample Output : 3\n",
100+
"\n",
101+
"3 2 1"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": 50,
107+
"metadata": {},
108+
"outputs": [
109+
{
110+
"data": {
111+
"text/plain": [
112+
"[3, 3, 1, 3, 1]"
113+
]
114+
},
115+
"execution_count": 50,
116+
"metadata": {},
117+
"output_type": "execute_result"
118+
}
119+
],
120+
"source": [
121+
"def WordsRepeat(m):\n",
122+
" n=[]\n",
123+
" for i in range(len(m)):\n",
124+
" n.append(m.count(m[i]))\n",
125+
" return(n)\n",
126+
"WordsRepeat([\"abcd\",\"abcd\",\"pqrs\",\"abcd\",\"ijkl\"])"
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"execution_count": null,
132+
"metadata": {},
133+
"outputs": [],
134+
"source": []
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"metadata": {},
139+
"source": [
140+
"## Problem 4:\n",
141+
"## Statement:\n",
142+
"Define a function to validate email addresses based on the following rules.\n",
143+
"\n",
144+
"Email should be in the format username@domain.extension\n",
145+
"username must start with an alphabet and can contain lowercase alphabet, digits, hyphen(-) and underscores( _ ).\n",
146+
"username must not contain special characters, uppercase letters, whitespaces.\n",
147+
"Length of username must be in the range (6, 16)\n",
148+
"Domain can only contain lowercase alphabet and digits with length in range (3, 10) . No special characters are allowed\n",
149+
"Extension can only contain lower case alphabet and its length must be in the range (2, 4)\n",
150+
"First line of input contains total number of email addresses n. Next n lines contain n email addresses.\n",
151+
"\n",
152+
"Output must contain contain n lines with either 'Valid' or 'Invalid'\n",
153+
"### Test Cases:\n",
154+
"Sample Input : 6\n",
155+
"\n",
156+
"abc456@gmail.com\n",
157+
"\n",
158+
"456abc@yahoo.com\n",
159+
"\n",
160+
"abc_456@gitam.ed1\n",
161+
"\n",
162+
"abc-456@abc-d.in\n",
163+
"\n",
164+
"python@python.edu\n",
165+
"\n",
166+
"abc 456@edu.edu\n",
167+
"\n",
168+
"Sample Output : Valid\n",
169+
"\n",
170+
"Invalid\n",
171+
"\n",
172+
"Invalid\n",
173+
"\n",
174+
"Invalid\n",
175+
"\n",
176+
"Valid\n",
177+
"\n",
178+
"Invalid"
179+
]
180+
},
181+
{
182+
"cell_type": "code",
183+
"execution_count": 62,
184+
"metadata": {},
185+
"outputs": [
186+
{
187+
"name": "stdout",
188+
"output_type": "stream",
189+
"text": [
190+
"abc456 Invalid\n",
191+
"\n",
192+
"456abc Invalid\n",
193+
"\n",
194+
"abc_456 Invalid\n",
195+
"\n",
196+
"abc-456 Invalid\n",
197+
"\n",
198+
"python Invalid\n",
199+
"\n",
200+
"abc 456 Invalid\n",
201+
"\n"
202+
]
203+
}
204+
],
205+
"source": [
206+
"def correctMail(m):\n",
207+
" sc={1 : '!',2:'@',3:'#',4:'$',5:'%',6:'^',7:'&',8:'*',9:'/',10:'=',11:'+'}\n",
208+
" n={1:'1',2:'2',3:'3',4:'4',5:'5',6:'6',7:'7',8:'8',9:'9',10:'0',11:' '}\n",
209+
" s=m.split('@')\n",
210+
" if (s[0]==s[0].isupper() or s[0]==sc or len(s[0])<6 or len(s[0])>16 or s[0][0]==s[0][0].lower() ):\n",
211+
" print(s[0],\"Invalid\")\n",
212+
" for i in range (len(sc)):\n",
213+
" if s[0]==s[0].find('sc[i]') or s[0]==s[0].find('n[i]') :\n",
214+
" print(s[0],\"Invalid\")\n",
215+
" else:\n",
216+
" return ''\n",
217+
" else:\n",
218+
" return 'Valid'\n",
219+
"print(correctMail(\"abc456@gmail.com\"))\n",
220+
"print(correctMail(\"456abc@yahoo.com\"))\n",
221+
"print(correctMail(\"abc_456@gitam.ed1\"))\n",
222+
"print(correctMail(\"abc-456@abc-d.in\"))\n",
223+
"print(correctMail(\"python@python.edu\"))\n",
224+
"print(correctMail(\"abc 456@edu.edu\"))"
225+
]
226+
},
227+
{
228+
"cell_type": "code",
229+
"execution_count": null,
230+
"metadata": {},
231+
"outputs": [],
232+
"source": []
233+
}
234+
],
235+
"metadata": {
236+
"kernelspec": {
237+
"display_name": "Python 3",
238+
"language": "python",
239+
"name": "python3"
240+
},
241+
"language_info": {
242+
"codemirror_mode": {
243+
"name": "ipython",
244+
"version": 3
245+
},
246+
"file_extension": ".py",
247+
"mimetype": "text/x-python",
248+
"name": "python",
249+
"nbconvert_exporter": "python",
250+
"pygments_lexer": "ipython3",
251+
"version": "3.7.3"
252+
}
253+
},
254+
"nbformat": 4,
255+
"nbformat_minor": 2
256+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /