Skip to content

Commit 937f151

Browse files
Module Test 2
1 parent 1c9e89f commit 937f151

File tree

1 file changed

+218
-0
lines changed

1 file changed

+218
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"n=b"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 2,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"name": "stdout",
17+
"output_type": "stream",
18+
"text": [
19+
"1\n",
20+
"21\n",
21+
"42\n"
22+
]
23+
}
24+
],
25+
"source": [
26+
"a=int(input())\n",
27+
"c=int(input())\n",
28+
"if (a+c)>=20 and (a+c)<=40:\n",
29+
" print(42)\n",
30+
"else:\n",
31+
" print(a+c)"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 21,
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"name": "stdout",
41+
"output_type": "stream",
42+
"text": [
43+
"9\n"
44+
]
45+
},
46+
{
47+
"data": {
48+
"text/plain": [
49+
"True"
50+
]
51+
},
52+
"execution_count": 21,
53+
"metadata": {},
54+
"output_type": "execute_result"
55+
}
56+
],
57+
"source": [
58+
"'''\n",
59+
"Given a non-negative number n, print True if n is within 2 of a multiple of 10, else print false. For example 22 is within 2 of a multiple of 10 (the multiple here is 20) and 23 is not within 2 of a multiple of 10 (it is within 3 of multiple 20).\n",
60+
"\n",
61+
"Input Format:\n",
62+
"The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains a number n.\n",
63+
"\n",
64+
"Output Format:\n",
65+
"For each testcase, in a new line, print True if conditions are met; else print False.\n",
66+
"\n",
67+
"Your Task:\n",
68+
"This is a function problem. Do not take any input. Just complete the function isNeighbor\n",
69+
"\n",
70+
"Constraints:\n",
71+
"1 <= T <= 100\n",
72+
"3 <= n <= 1018\n",
73+
"\n",
74+
"Example:\n",
75+
"Input:\n",
76+
"4\n",
77+
"3\n",
78+
"9\n",
79+
"13\n",
80+
"22\n",
81+
"Output:\n",
82+
"False\n",
83+
"True\n",
84+
"False\n",
85+
"True\n",
86+
"'''\n",
87+
"\n",
88+
"def near_ten(num):\n",
89+
"\n",
90+
" a = num % 10\n",
91+
" if a <= 2 or (10 - a) <= 2:\n",
92+
" return True\n",
93+
" else:\n",
94+
" return False\n",
95+
"near_ten(int(input()))"
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": 11,
101+
"metadata": {},
102+
"outputs": [
103+
{
104+
"name": "stdout",
105+
"output_type": "stream",
106+
"text": [
107+
"dog\n"
108+
]
109+
},
110+
{
111+
"data": {
112+
"text/plain": [
113+
"0"
114+
]
115+
},
116+
"execution_count": 11,
117+
"metadata": {},
118+
"output_type": "execute_result"
119+
}
120+
],
121+
"source": [
122+
"s=input()\n",
123+
"c=0\n",
124+
"for i in range(26):\n",
125+
" c+=s.count('do'+chr(97+i)+'e')\n",
126+
"c"
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"execution_count": 8,
132+
"metadata": {},
133+
"outputs": [
134+
{
135+
"data": {
136+
"text/plain": [
137+
"97"
138+
]
139+
},
140+
"execution_count": 8,
141+
"metadata": {},
142+
"output_type": "execute_result"
143+
}
144+
],
145+
"source": [
146+
"ord('a')"
147+
]
148+
},
149+
{
150+
"cell_type": "code",
151+
"execution_count": 9,
152+
"metadata": {},
153+
"outputs": [
154+
{
155+
"data": {
156+
"text/plain": [
157+
"'a'"
158+
]
159+
},
160+
"execution_count": 9,
161+
"metadata": {},
162+
"output_type": "execute_result"
163+
}
164+
],
165+
"source": [
166+
"chr(97)"
167+
]
168+
},
169+
{
170+
"cell_type": "code",
171+
"execution_count": 12,
172+
"metadata": {},
173+
"outputs": [
174+
{
175+
"data": {
176+
"text/plain": [
177+
"1"
178+
]
179+
},
180+
"execution_count": 12,
181+
"metadata": {},
182+
"output_type": "execute_result"
183+
}
184+
],
185+
"source": [
186+
"(7**100)%5"
187+
]
188+
},
189+
{
190+
"cell_type": "code",
191+
"execution_count": null,
192+
"metadata": {},
193+
"outputs": [],
194+
"source": []
195+
}
196+
],
197+
"metadata": {
198+
"kernelspec": {
199+
"display_name": "Python 3",
200+
"language": "python",
201+
"name": "python3"
202+
},
203+
"language_info": {
204+
"codemirror_mode": {
205+
"name": "ipython",
206+
"version": 3
207+
},
208+
"file_extension": ".py",
209+
"mimetype": "text/x-python",
210+
"name": "python",
211+
"nbconvert_exporter": "python",
212+
"pygments_lexer": "ipython3",
213+
"version": "3.7.5"
214+
}
215+
},
216+
"nbformat": 4,
217+
"nbformat_minor": 2
218+
}

0 commit comments

Comments
 (0)