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 3d8e208

Browse files
Add files via upload
1 parent 0b05466 commit 3d8e208

File tree

1 file changed

+197
-0
lines changed

1 file changed

+197
-0
lines changed

‎Assignment-13.ipynb

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 22,
6+
"id": "038cc6d7",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"Enter numbers: 100,150,180\n",
14+
"The output of the given formula is 18 22 24\n"
15+
]
16+
}
17+
],
18+
"source": [
19+
"import math\n",
20+
"C = 50\n",
21+
"H = 30\n",
22+
"D = list(input(\"Enter numbers: \").split(\",\"))\n",
23+
"emplst=[]\n",
24+
"result=[]\n",
25+
"for value in D:\n",
26+
" g=int(value)\n",
27+
" emplst.append(g)\n",
28+
"for res in emplst:\n",
29+
" op = math.sqrt((2*C*res)/H)\n",
30+
" result.append(math.floor(op))\n",
31+
"print(\"The output of the given formula is \",*result)"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 31,
37+
"id": "98689957",
38+
"metadata": {},
39+
"outputs": [
40+
{
41+
"name": "stdout",
42+
"output_type": "stream",
43+
"text": [
44+
"Enter number of rows: 3\n",
45+
"Enter number of columns: 5\n",
46+
"[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]\n"
47+
]
48+
}
49+
],
50+
"source": [
51+
"i = int(input(\"Enter number of rows: \"))\n",
52+
"j = int(input(\"Enter number of columns: \"))\n",
53+
"matrix = [[0 for col in range(j)] for row in range(i)]\n",
54+
"for row in range(i):\n",
55+
" for col in range(j):\n",
56+
" matrix[row][col]=row*col\n",
57+
"print(matrix)"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": 41,
63+
"id": "d57df32d",
64+
"metadata": {},
65+
"outputs": [
66+
{
67+
"name": "stdout",
68+
"output_type": "stream",
69+
"text": [
70+
"Enter words: without,hello,bag,world\n",
71+
"bag, hello, without, world, "
72+
]
73+
}
74+
],
75+
"source": [
76+
"str_list = list(input(\"Enter words: \").split(\",\"))\n",
77+
"str_list.sort()\n",
78+
"for i in str_list:\n",
79+
" print(i+\",\",end=\" \")"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 42,
85+
"id": "251110aa",
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"name": "stdout",
90+
"output_type": "stream",
91+
"text": [
92+
"Enter words: hello world and practice makes perfect and hello world again\n",
93+
"again and hello makes perfect practice world\n"
94+
]
95+
}
96+
],
97+
"source": [
98+
"str_list = list(input(\"Enter words: \").split(\" \"))\n",
99+
"st = set(str_list)\n",
100+
"res=list(st)\n",
101+
"res.sort()\n",
102+
"print(*res)"
103+
]
104+
},
105+
{
106+
"cell_type": "code",
107+
"execution_count": 66,
108+
"id": "da0e43cb",
109+
"metadata": {},
110+
"outputs": [
111+
{
112+
"name": "stdout",
113+
"output_type": "stream",
114+
"text": [
115+
"Input a string: hello world! 123\n",
116+
"LETTERS: 10\n",
117+
"DIGITS: 3\n"
118+
]
119+
}
120+
],
121+
"source": [
122+
"import re\n",
123+
"str = input(\"Input a string: \")\n",
124+
"res=re.findall(\"[a-z0-9]\",str)\n",
125+
"letters=[]\n",
126+
"digits=[]\n",
127+
"for val in res:\n",
128+
" if val.isalpha():\n",
129+
" letters.append(val)\n",
130+
" else: \n",
131+
" digits.append(val)\n",
132+
"print(\"LETTERS: \",len(letters))\n",
133+
"print(\"DIGITS: \",len(digits)) "
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": 71,
139+
"id": "5adb5b42",
140+
"metadata": {},
141+
"outputs": [
142+
{
143+
"name": "stdout",
144+
"output_type": "stream",
145+
"text": [
146+
"Enter Password: ABd1234@1,a F1#,2w3E*,2We3345\n",
147+
"The accepted password is ABd1234@1\n"
148+
]
149+
}
150+
],
151+
"source": [
152+
"passwords = input(\"Enter Password: \").split(\",\")\n",
153+
"accepted_passwords = []\n",
154+
"for i in passwords: \n",
155+
" if len(i) < 6 or len(i) > 12:\n",
156+
" continue\n",
157+
"\n",
158+
" elif not re.search(\"([a-z])+\", i):\n",
159+
" continue\n",
160+
"\n",
161+
" elif not re.search(\"([A-Z])+\", i):\n",
162+
" continue\n",
163+
"\n",
164+
" elif not re.search(\"([0-9])+\", i):\n",
165+
" continue\n",
166+
"\n",
167+
" elif not re.search(\"([!@$%^&])+\", i):\n",
168+
" continue\n",
169+
"\n",
170+
" else:\n",
171+
" accepted_passwords.append(i)\n",
172+
"print(\"The accepted password is \",*accepted_passwords)"
173+
]
174+
}
175+
],
176+
"metadata": {
177+
"kernelspec": {
178+
"display_name": "Python 3",
179+
"language": "python",
180+
"name": "python3"
181+
},
182+
"language_info": {
183+
"codemirror_mode": {
184+
"name": "ipython",
185+
"version": 3
186+
},
187+
"file_extension": ".py",
188+
"mimetype": "text/x-python",
189+
"name": "python",
190+
"nbconvert_exporter": "python",
191+
"pygments_lexer": "ipython3",
192+
"version": "3.6.9"
193+
}
194+
},
195+
"nbformat": 4,
196+
"nbformat_minor": 5
197+
}

0 commit comments

Comments
(0)

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