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 78e6543

Browse files
netflix
1 parent 2a0cef6 commit 78e6543

8 files changed

+16929
-0
lines changed

‎Competitive Coding/practice/.ipynb_checkpoints/basic python-checkpoint.ipynb

Lines changed: 484 additions & 0 deletions
Large diffs are not rendered by default.

‎Competitive Coding/practice/.ipynb_checkpoints/numpy and pandas-checkpoint.ipynb

Lines changed: 1370 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"id": "8fKYMwIkIyiQ"
7+
},
8+
"source": [
9+
"In a school, there are total 100 students numbered from 1 to 100. You’re given three lists named ‘C’, ‘F’, and ‘H’, representing students who play cricket, football, and hockey, respectively. Based on this information, find out and print the following: \n",
10+
"- Students who play all the three sports\n",
11+
"- Students who play both cricket and football but don’t play hockey\n",
12+
"- Students who play exactly two of the sports\n",
13+
"- Students who don’t play any of the three sports"
14+
]
15+
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": 1,
19+
"metadata": {
20+
"id": "5l7a4uNYIyik"
21+
},
22+
"outputs": [],
23+
"source": [
24+
"C = [7, 8, 9, 18, 20, 21, 25, 26, 27, 31, 32, 34, 35, 36, 40, 43, 45, 47, 53, 58, 62, 67, 68, 71, 72, 74, 75, 76, 80, 81, 82, 90, 93, 95, 97, 99]\n",
25+
"F = [1, 7, 10, 13, 16, 22, 24, 29, 30, 32, 34, 39, 40, 43, 44, 48, 56, 60, 65, 68, 69, 73, 77, 78, 90, 93, 94, 95, 96]\n",
26+
"H = [5, 12, 14, 17, 20, 21, 22, 25, 28, 30, 37, 38, 39, 40, 42, 44, 57, 59, 61, 62, 67, 71, 75, 76, 77, 82, 83, 86, 87, 92, 94, 95]"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"metadata": {
32+
"id": "UK1l0kibIyjB"
33+
},
34+
"source": [
35+
"#### Q1. Which are the students who play all the three sports?\n",
36+
"- [22, 39]\n",
37+
"- [39, 82]\n",
38+
"- [40, 95]\n",
39+
"- [82, 94]"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"source": [
45+
"set.intersection(set(C), set(F), set(H))"
46+
],
47+
"metadata": {
48+
"colab": {
49+
"base_uri": "https://localhost:8080/"
50+
},
51+
"id": "nvtvxk_pI9gf",
52+
"outputId": "cb89b1bd-bb34-445e-a25e-017a146409fb"
53+
},
54+
"execution_count": 5,
55+
"outputs": [
56+
{
57+
"output_type": "execute_result",
58+
"data": {
59+
"text/plain": [
60+
"{40, 95}"
61+
]
62+
},
63+
"metadata": {},
64+
"execution_count": 5
65+
}
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {
71+
"id": "txLxtV1EIyjE"
72+
},
73+
"source": [
74+
"#### Q2. Which are the players who play both cricket and hockey but don't play football?\n",
75+
"- [20, 21, 25, 62, 67, 71, 75, 76, 82]\n",
76+
"- [20, 21, 22, 25, 30, 32, 34]\n",
77+
"- [20, 21, 22, 25, 30, 32, 34, 39, 43, 44, 62]\n",
78+
"- [20, 21, 68, 71, 75, 76]"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"source": [
84+
"set.intersection(set(C), set(H)) - set(F)"
85+
],
86+
"metadata": {
87+
"colab": {
88+
"base_uri": "https://localhost:8080/"
89+
},
90+
"id": "lFy-sg3JJcTm",
91+
"outputId": "6b29cbe9-6405-4023-f910-8337969d625f"
92+
},
93+
"execution_count": 8,
94+
"outputs": [
95+
{
96+
"output_type": "execute_result",
97+
"data": {
98+
"text/plain": [
99+
"{20, 21, 25, 62, 67, 71, 75, 76, 82}"
100+
]
101+
},
102+
"metadata": {},
103+
"execution_count": 8
104+
}
105+
]
106+
},
107+
{
108+
"cell_type": "markdown",
109+
"metadata": {
110+
"id": "m1Lktna8IyjH"
111+
},
112+
"source": [
113+
"#### Q3. How many players play exactly two sports?\n",
114+
"- 19\n",
115+
"- 20\n",
116+
"- 21\n",
117+
"- 22"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"source": [
123+
"len(set.union(set.intersection(set(C), set(F)), set.intersection(set(F), set(H)), set.intersection(set(H), set(C))) - set.intersection(set(C), set(F), set(H)))"
124+
],
125+
"metadata": {
126+
"colab": {
127+
"base_uri": "https://localhost:8080/"
128+
},
129+
"id": "V9AiMe2DJ5M9",
130+
"outputId": "72af4496-087b-4473-80bd-71e42de26a59"
131+
},
132+
"execution_count": 15,
133+
"outputs": [
134+
{
135+
"output_type": "execute_result",
136+
"data": {
137+
"text/plain": [
138+
"22"
139+
]
140+
},
141+
"metadata": {},
142+
"execution_count": 15
143+
}
144+
]
145+
},
146+
{
147+
"cell_type": "markdown",
148+
"metadata": {
149+
"id": "FSsKOWgCIyjL"
150+
},
151+
"source": [
152+
"#### Q4. Which of these students do not play any of the sports? (More than one option may be correct)\n",
153+
"- 41\n",
154+
"- 48\n",
155+
"- 63\n",
156+
"- 85"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"source": [
162+
"for i in [41, 48, 63, 85]:\n",
163+
" if i in set(range(1, 101)) - set.union(set(C), set(F), set(H)):\n",
164+
" print(i)"
165+
],
166+
"metadata": {
167+
"colab": {
168+
"base_uri": "https://localhost:8080/"
169+
},
170+
"id": "oUwtNE47Mt9R",
171+
"outputId": "e2e1b2ba-c697-4ee4-9fcb-7557e61dd68d"
172+
},
173+
"execution_count": 22,
174+
"outputs": [
175+
{
176+
"output_type": "stream",
177+
"name": "stdout",
178+
"text": [
179+
"41\n",
180+
"63\n",
181+
"85\n"
182+
]
183+
}
184+
]
185+
},
186+
{
187+
"cell_type": "code",
188+
"source": [],
189+
"metadata": {
190+
"id": "roB-CnoyM4f0"
191+
},
192+
"execution_count": null,
193+
"outputs": []
194+
}
195+
],
196+
"metadata": {
197+
"kernelspec": {
198+
"display_name": "Python 3",
199+
"language": "python",
200+
"name": "python3"
201+
},
202+
"language_info": {
203+
"codemirror_mode": {
204+
"name": "ipython",
205+
"version": 3
206+
},
207+
"file_extension": ".py",
208+
"mimetype": "text/x-python",
209+
"name": "python",
210+
"nbconvert_exporter": "python",
211+
"pygments_lexer": "ipython3",
212+
"version": "3.6.5"
213+
},
214+
"colab": {
215+
"provenance": []
216+
}
217+
},
218+
"nbformat": 4,
219+
"nbformat_minor": 0
220+
}

0 commit comments

Comments
(0)

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