Skip to content

Commit 72a4661

Browse files
committed
first commit
0 parents  commit 72a4661

1 file changed

Lines changed: 306 additions & 0 deletions

File tree

AI LAB TASK 1.ipynb

Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"y and z are not equal\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"# Assignment operator (=)\n",
18+
"x = 55 # Assigning the value 5 to the variable x\n",
19+
"\n",
20+
"# Equality operator (==)\n",
21+
"y = 10\n",
22+
"z = 52\n",
23+
"\n",
24+
"# Check if y is equal to z\n",
25+
"if y == z:\n",
26+
" print(\"y and z are equal\")\n",
27+
"else:\n",
28+
" print(\"y and z are not equal\")\n"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 4,
34+
"metadata": {},
35+
"outputs": [
36+
{
37+
"name": "stdout",
38+
"output_type": "stream",
39+
"text": [
40+
"Integer Variable: 11 Type: <class 'int'>\n",
41+
"Floating-point Variable: 7.14 Type: <class 'float'>\n",
42+
"String Variable: Hello, World! Type: <class 'str'>\n",
43+
"Boolean Variable: True Type: <class 'bool'>\n"
44+
]
45+
}
46+
],
47+
"source": [
48+
"# Integer variable\n",
49+
"int = 11\n",
50+
"\n",
51+
"# Floating-point variable\n",
52+
"float = 7.14\n",
53+
"\n",
54+
"# String variable\n",
55+
"string = \"Hello, World!\"\n",
56+
"\n",
57+
"# Boolean variable\n",
58+
"boolean = True\n",
59+
"\n",
60+
"# Printing the variables to verify their types\n",
61+
"print(\"Integer Variable:\", int, \"Type:\", type(int))\n",
62+
"print(\"Floating-point Variable:\", float, \"Type:\", type(float))\n",
63+
"print(\"String Variable:\", string, \"Type:\", type(string))\n",
64+
"print(\"Boolean Variable:\", boolean, \"Type:\", type(boolean))\n"
65+
]
66+
},
67+
{
68+
"cell_type": "code",
69+
"execution_count": 8,
70+
"metadata": {},
71+
"outputs": [
72+
{
73+
"name": "stdout",
74+
"output_type": "stream",
75+
"text": [
76+
"my_variable: 10\n",
77+
"myVariable: 20\n",
78+
"my_variable2: 30\n",
79+
"_my_variable: 40\n",
80+
"MY_VARIABLE: 50\n",
81+
"my_variable: 60\n",
82+
"my variable: 70\n",
83+
"my_variable3: 80\n",
84+
"variable123: 90\n",
85+
"_variable_: 100\n"
86+
]
87+
}
88+
],
89+
"source": [
90+
"# Valid variable names\n",
91+
"my_variable = 10\n",
92+
"myVariable = 20\n",
93+
"my_variable2 = 30\n",
94+
"_my_variable = 40\n",
95+
"MY_VARIABLE = 50\n",
96+
"\n",
97+
"# Variable names with special characters and numbers\n",
98+
"my_variablee = 60\n",
99+
"my_variable1 = 70\n",
100+
"my_variable3 = 80\n",
101+
"variable123 = 90\n",
102+
"_variable_ = 100\n",
103+
"\n",
104+
"# Printing the values of variables\n",
105+
"print(\"my_variable:\", my_variable)\n",
106+
"print(\"myVariable:\", myVariable)\n",
107+
"print(\"my_variable2:\", my_variable2)\n",
108+
"print(\"_my_variable:\", _my_variable)\n",
109+
"print(\"MY_VARIABLE:\", MY_VARIABLE)\n",
110+
"\n",
111+
"print(\"my_variable:\", my_variablee)\n",
112+
"print(\"my variable:\", my_variable1)\n",
113+
"print(\"my_variable3:\", my_variable3)\n",
114+
"print(\"variable123:\", variable123)\n",
115+
"print(\"_variable_:\", _variable_)\n"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": 12,
121+
"metadata": {},
122+
"outputs": [
123+
{
124+
"name": "stdout",
125+
"output_type": "stream",
126+
"text": [
127+
"Assigning variable with multiple values:\n",
128+
"x: 10 y: 20 z: 30\n",
129+
"name1: Ali name2: Bobby name3: PAF\n",
130+
"\n",
131+
"Multiple variables with single values:\n",
132+
"a: 5 b: 5 c: 5\n",
133+
"age: 25 height: 180 weight: 75\n"
134+
]
135+
}
136+
],
137+
"source": [
138+
"# variable with multiple values\n",
139+
"x, y, z = 10, 20, 30\n",
140+
"name1, name2, name3 = \"Ali\", \"Bobby\", \"PAF\"\n",
141+
"\n",
142+
"# Multiple variables with single values\n",
143+
"a = b = c = 5\n",
144+
"age, height, weight = 25, 180, 75\n",
145+
"\n",
146+
"# Printing variables \n",
147+
"print(\"Assigning variable with multiple values:\")\n",
148+
"print(\"x:\", x, \"y:\", y, \"z:\", z)\n",
149+
"print(\"name1:\", name1, \"name2:\", name2, \"name3:\", name3)\n",
150+
"\n",
151+
"print(\"\\nMultiple variables with single values:\")\n",
152+
"print(\"a:\", a, \"b:\", b, \"c:\", c)\n",
153+
"print(\"age:\", age, \"height:\", height, \"weight:\", weight)\n"
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": 13,
159+
"metadata": {},
160+
"outputs": [
161+
{
162+
"name": "stdout",
163+
"output_type": "stream",
164+
"text": [
165+
"Arithmetic operations on integers:\n",
166+
"Addition: 15\n",
167+
"Subtraction: 5\n",
168+
"Multiplication: 50\n",
169+
"Division: 1.75\n",
170+
"Division: 2.0\n",
171+
"\n",
172+
"Arithmetic operations on floating-point numbers:\n",
173+
"Addition: 5.5\n",
174+
"Subtraction: 1.5\n",
175+
"Multiplication: 7.0\n"
176+
]
177+
}
178+
],
179+
"source": [
180+
"# Integers\n",
181+
"a = 10\n",
182+
"b = 5\n",
183+
"\n",
184+
"# Floating-point numbers\n",
185+
"x = 3.5\n",
186+
"y = 2.0\n",
187+
"\n",
188+
"# Arithmetic operations on integers\n",
189+
"add = a + b\n",
190+
"subt = a - b\n",
191+
"multipl = a * b\n",
192+
"divi = a / b\n",
193+
"\n",
194+
"# Arithmetic operations on floating-point numbers\n",
195+
"add_float = x + y\n",
196+
"subt_float = x - y\n",
197+
"multip_float = x * y\n",
198+
"div_float = x / y\n",
199+
"\n",
200+
"# Printing results\n",
201+
"print(\"Arithmetic operations on integers:\")\n",
202+
"print(\"Addition:\", add)\n",
203+
"print(\"Subtraction:\", subt)\n",
204+
"print(\"Multiplication:\", multipl)\n",
205+
"print(\"Division:\", div_float)\n",
206+
"print(\"Division:\", divi)\n",
207+
"\n",
208+
"print(\"\\nArithmetic operations on floating-point numbers:\")\n",
209+
"print(\"Addition:\", add_float)\n",
210+
"print(\"Subtraction:\", subt_float)\n",
211+
"print(\"Multiplication:\", multip_float)\n"
212+
]
213+
},
214+
{
215+
"cell_type": "code",
216+
"execution_count": 14,
217+
"metadata": {},
218+
"outputs": [
219+
{
220+
"name": "stdout",
221+
"output_type": "stream",
222+
"text": [
223+
"Hello, world!\n",
224+
"Hello, world!\n",
225+
"She said, 'Hello!'\n",
226+
"He replied, \"Hi!\"\n"
227+
]
228+
}
229+
],
230+
"source": [
231+
"# Using single quotes\n",
232+
"single_string = 'Hello, world!'\n",
233+
"\n",
234+
"# Using double quotes\n",
235+
"double_string = \"Hello, world!\"\n",
236+
"\n",
237+
"# Using double quotes when the string contains a single quote\n",
238+
"double_quotes_single_quote = \"She said, 'Hello!'\"\n",
239+
"\n",
240+
"# Using single quotes when the string contains double quotes\n",
241+
"single_quotes_double_quotes = 'He replied, \"Hi!\"'\n",
242+
"\n",
243+
"# Printing the strings\n",
244+
"print(single_string)\n",
245+
"print(double_string)\n",
246+
"print(double_quotes_single_quote)\n",
247+
"print(single_quotes_double_quotes)\n"
248+
]
249+
},
250+
{
251+
"cell_type": "code",
252+
"execution_count": 16,
253+
"metadata": {},
254+
"outputs": [
255+
{
256+
"name": "stdout",
257+
"output_type": "stream",
258+
"text": [
259+
"Ali\n",
260+
"Name: Ali Age: 22 City: New York\n",
261+
"Name: Ali, Age: 22, City: New York\n",
262+
"The result multiplied is: 77\n"
263+
]
264+
}
265+
],
266+
"source": [
267+
"# Example of using the print() function to output a variable\n",
268+
"name = \"Ali\"\n",
269+
"print(name)\n",
270+
"\n",
271+
"# Example of outputting multiple variables with print()\n",
272+
"age = 22\n",
273+
"city = \"New York\"\n",
274+
"print(\"Name:\", name, \"Age:\", age, \"City:\", city)\n",
275+
"\n",
276+
"# Example of using f-strings to format output\n",
277+
"print(f\"Name: {name}, Age: {age}, City: {city}\")\n",
278+
"\n",
279+
"# Example of using f-strings to manipulate variables in output\n",
280+
"result = 11\n",
281+
"print(f\"The result multiplied is: {result * 7}\")\n"
282+
]
283+
}
284+
],
285+
"metadata": {
286+
"kernelspec": {
287+
"display_name": "Python 3",
288+
"language": "python",
289+
"name": "python3"
290+
},
291+
"language_info": {
292+
"codemirror_mode": {
293+
"name": "ipython",
294+
"version": 3
295+
},
296+
"file_extension": ".py",
297+
"mimetype": "text/x-python",
298+
"name": "python",
299+
"nbconvert_exporter": "python",
300+
"pygments_lexer": "ipython3",
301+
"version": "3.12.0"
302+
}
303+
},
304+
"nbformat": 4,
305+
"nbformat_minor": 2
306+
}

0 commit comments

Comments
 (0)