Skip to content

Commit 2ce3881

Browse files
authored
Add files via upload
Lab task:7
1 parent f1033f8 commit 2ce3881

1 file changed

Lines changed: 212 additions & 0 deletions

File tree

Untitled-1.ipynb

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Muhammad Abdullah\n",
8+
"\n",
9+
"B22F0577AI054\n",
10+
"\n",
11+
"AI BLUE\n",
12+
"\n",
13+
"LAB TASK:7\n",
14+
"\n",
15+
"Submitted To: Mam Anila Habib"
16+
]
17+
},
18+
{
19+
"cell_type": "markdown",
20+
"metadata": {},
21+
"source": [
22+
"Task:1\n",
23+
"\n",
24+
" Program to determine the quadrant of a point in a 2D plane\n",
25+
"\n",
26+
"Using of 4 if conditions:"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 1,
32+
"metadata": {},
33+
"outputs": [
34+
{
35+
"name": "stdout",
36+
"output_type": "stream",
37+
"text": [
38+
"The point is in the first quadrant\n"
39+
]
40+
}
41+
],
42+
"source": [
43+
"x = float(input(\"Enter the x-coordinate: \"))\n",
44+
"y = float(input(\"Enter the y-coordinate: \"))\n",
45+
"\n",
46+
"if x > 0 and y > 0:\n",
47+
" print(\"The point is in the first quadrant\")\n",
48+
"if x < 0 and y > 0:\n",
49+
" print(\"The point is in the second quadrant\")\n",
50+
"if x < 0 and y < 0:\n",
51+
" print(\"The point is in the third quadrant\")\n",
52+
"if x > 0 and y < 0:\n",
53+
" print(\"The point is in the fourth quadrant\")"
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"metadata": {},
59+
"source": [
60+
"Result:\n",
61+
"\n",
62+
"In this program, we use four if conditions to determine the quadrant of a point in a 2D plane based on its x and y coordinates. Each if condition checks a specific combination of x and y values to determine the quadrant in which the point lies."
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"Task:2\n",
70+
"\n",
71+
"Write a program of nested if conditions \n",
72+
"\n",
73+
"Program to determine the quadrant of a point in a 2D plane using nested if conditions"
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"metadata": {},
80+
"outputs": [],
81+
"source": [
82+
"x = float(input(\"Enter the x-coordinate: \"))\n",
83+
"y = float(input(\"Enter the y-coordinate: \"))\n",
84+
"\n",
85+
"if x > 0:\n",
86+
" if y > 0:\n",
87+
" print(\"The point is in the first quadrant\")\n",
88+
" if y < 0:\n",
89+
" print(\"The point is in the fourth quadrant\")\n",
90+
"if x < 0:\n",
91+
" if y > 0:\n",
92+
" print(\"The point is in the second quadrant\")\n",
93+
" if y < 0:\n",
94+
" print(\"The point is in the third quadrant\")"
95+
]
96+
},
97+
{
98+
"cell_type": "markdown",
99+
"metadata": {},
100+
"source": [
101+
"Result:\n",
102+
"\n",
103+
"In this program, we use nested if conditions to determine the quadrant of a point in a 2D plane. The outer if conditions check the sign of the x-coordinate, and the inner if conditions check the sign of the y-coordinate to determine the quadrant."
104+
]
105+
},
106+
{
107+
"cell_type": "markdown",
108+
"metadata": {},
109+
"source": [
110+
"Task:3\n",
111+
"\n",
112+
"Program that determines the quadrant of a point based on its x and y coordinates using if-else statements:\n"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"metadata": {},
119+
"outputs": [],
120+
"source": [
121+
"\n",
122+
"\n",
123+
"x = float(input(\"Enter the x-coordinate of the point: \"))\n",
124+
"y = float(input(\"Enter the y-coordinate of the point: \"))\n",
125+
"\n",
126+
"if x > 0:\n",
127+
" if y > 0:\n",
128+
" print(\"The point is in the first quadrant\")\n",
129+
" else:\n",
130+
" print(\"The point is in the fourth quadrant\")\n",
131+
"else:\n",
132+
" if y > 0:\n",
133+
" print(\"The point is in the second quadrant\")\n",
134+
" else:\n",
135+
" print(\"The point is in the third quadrant\")"
136+
]
137+
},
138+
{
139+
"cell_type": "markdown",
140+
"metadata": {},
141+
"source": [
142+
"Result:\n",
143+
"\n",
144+
"In this program, the user inputs the x and y coordinates of a point. The program then uses nested if-else statements to determine the quadrant in which the point lies based on the signs of its x and y coordinates. The output indicates the quadrant in which the point is located."
145+
]
146+
},
147+
{
148+
"cell_type": "markdown",
149+
"metadata": {},
150+
"source": [
151+
"Task:4\n",
152+
"\n",
153+
" Python program that uses nested if-else statements to determine the quadrant in which a point lies based on its x and y coordinates:"
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": null,
159+
"metadata": {},
160+
"outputs": [],
161+
"source": [
162+
"# Input x and y coordinates\n",
163+
"x = float(input(\"Enter the x-coordinate: \"))\n",
164+
"y = float(input(\"Enter the y-coordinate: \"))\n",
165+
"\n",
166+
"# Nested if-else statements to determine the quadrant\n",
167+
"if x > 0:\n",
168+
" if y > 0:\n",
169+
" print(\"The point is in the first quadrant\")\n",
170+
" else:\n",
171+
" print(\"The point is in the fourth quadrant\")\n",
172+
"else:\n",
173+
" if y > 0:\n",
174+
" print(\"The point is in the second quadrant\")\n",
175+
" else:\n",
176+
" print(\"The point is in the third quadrant\")"
177+
]
178+
},
179+
{
180+
"cell_type": "markdown",
181+
"metadata": {},
182+
"source": [
183+
"Result:\n",
184+
"\n",
185+
"We first input the x and y coordinates of a point.\n",
186+
"The program then uses nested if-else statements to check the signs of x and y to determine the quadrant in which the point lies.\n",
187+
"Depending on the conditions, it will output the quadrant in which the point is located."
188+
]
189+
}
190+
],
191+
"metadata": {
192+
"kernelspec": {
193+
"display_name": "Python 3",
194+
"language": "python",
195+
"name": "python3"
196+
},
197+
"language_info": {
198+
"codemirror_mode": {
199+
"name": "ipython",
200+
"version": 3
201+
},
202+
"file_extension": ".py",
203+
"mimetype": "text/x-python",
204+
"name": "python",
205+
"nbconvert_exporter": "python",
206+
"pygments_lexer": "ipython3",
207+
"version": "3.12.0"
208+
}
209+
},
210+
"nbformat": 4,
211+
"nbformat_minor": 2
212+
}

0 commit comments

Comments
 (0)