Skip to content

Commit 6a0980a

Browse files
committed
add more questions in Ex1_Python
1 parent 50ff9b5 commit 6a0980a

2 files changed

Lines changed: 105 additions & 15 deletions

File tree

Ex1_Python-Solution.ipynb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,27 @@
7878
},
7979
{
8080
"cell_type": "code",
81-
"execution_count": null,
81+
"execution_count": 10,
8282
"metadata": {
8383
"colab": {
8484
"base_uri": "https://localhost:8080/"
8585
},
8686
"id": "x9xQXOnRa0MS",
8787
"outputId": "64294c78-0769-4728-f781-9204a1aa51e3"
8888
},
89-
"outputs": [],
89+
"outputs": [
90+
{
91+
"name": "stdout",
92+
"output_type": "stream",
93+
"text": [
94+
"100 usd is equivalent to 82.0 british pound\n"
95+
]
96+
}
97+
],
9098
"source": [
9199
"usd_amount = input (\"Enter the amount in USD: \")\n",
92100
"bp_amount = int(usd_amount) *0.82\n",
101+
"\n",
93102
"print(\"{} usd is equivalent to {} british pound\".format(usd_amount, bp_amount))"
94103
]
95104
},
@@ -121,7 +130,9 @@
121130
"source": [
122131
"temp_F = input(\"Enter temperatre in F: \")\n",
123132
"temp_C = (int(temp_F)-32)*5/9\n",
124-
"print(\"{} Feranhite is equal to {:.2f} Celsius\".format(temp_F, temp_C))"
133+
"\n",
134+
"print(\"{} Feranhite is equal to {:.2f} Celsius\".format(temp_F, temp_C))\n",
135+
"\n"
125136
]
126137
},
127138
{
@@ -223,7 +234,7 @@
223234
"name": "python",
224235
"nbconvert_exporter": "python",
225236
"pygments_lexer": "ipython3",
226-
"version": "3.8.8"
237+
"version": "3.12.1"
227238
}
228239
},
229240
"nbformat": 4,

Ex1_Python.ipynb

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,7 @@
8383
"id": "x9xQXOnRa0MS",
8484
"outputId": "64294c78-0769-4728-f781-9204a1aa51e3"
8585
},
86-
"outputs": [
87-
{
88-
"name": "stdout",
89-
"output_type": "stream",
90-
"text": [
91-
"Enter the amount in USD: 1500\n",
92-
"1500 usd is equivalent to 1230.0 british pound\n"
93-
]
94-
}
95-
],
86+
"outputs": [],
9687
"source": [
9788
"usd_amount = input (\"Enter the amount in USD: \")\n",
9889
"bp_amount = int(usd_amount) *0.82\n",
@@ -179,6 +170,94 @@
179170
},
180171
"outputs": [],
181172
"source": []
173+
},
174+
{
175+
"cell_type": "markdown",
176+
"metadata": {},
177+
"source": [
178+
"# Ex 6: Random Number\n",
179+
"Write a program that generates a random number, x, between 1 and 50, a random number y between 2 and 5, and computes x^y."
180+
]
181+
},
182+
{
183+
"cell_type": "code",
184+
"execution_count": null,
185+
"metadata": {},
186+
"outputs": [],
187+
"source": [
188+
"from random import randint\n",
189+
"x = randint(1,10)\n",
190+
"print('A random number between 1 and 10: ', x)"
191+
]
192+
},
193+
{
194+
"cell_type": "markdown",
195+
"metadata": {},
196+
"source": [
197+
"# Ex 7: Greet many times.\n",
198+
"Write a program that generates a random number between 1 and 10 and prints your name that many times."
199+
]
200+
},
201+
{
202+
"cell_type": "code",
203+
"execution_count": null,
204+
"metadata": {},
205+
"outputs": [],
206+
"source": [
207+
"\n"
208+
]
209+
},
210+
{
211+
"cell_type": "markdown",
212+
"metadata": {},
213+
"source": [
214+
"# Ex 8: Computation. \n",
215+
"Write a program that asks the user to enter two numbers, x and y, and computes |x-y|/(x+y)."
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": null,
221+
"metadata": {},
222+
"outputs": [],
223+
"source": []
224+
},
225+
{
226+
"cell_type": "markdown",
227+
"metadata": {},
228+
"source": [
229+
"# Ex 9: Computing\n",
230+
"\n",
231+
"rite a program that asks the user for a number of seconds and prints out how many minutes and seconds that is. For instance, 200 seconds is 3 minutes and 20 seconds."
232+
]
233+
},
234+
{
235+
"cell_type": "code",
236+
"execution_count": null,
237+
"metadata": {},
238+
"outputs": [],
239+
"source": []
240+
},
241+
{
242+
"cell_type": "markdown",
243+
"metadata": {},
244+
"source": [
245+
"# Ex 10: Using Math Module\n",
246+
"\n",
247+
"Write a program that asks the user for a number and then prints out the sine, cosine, and tangent of that number."
248+
]
249+
},
250+
{
251+
"cell_type": "code",
252+
"execution_count": null,
253+
"metadata": {},
254+
"outputs": [],
255+
"source": [
256+
"import math\n",
257+
"num = float(input(\"Enter a number:\"))\n",
258+
"sine_value = math.sin(num)\n",
259+
"print(sine_value)\n"
260+
]
182261
}
183262
],
184263
"metadata": {
@@ -203,7 +282,7 @@
203282
"name": "python",
204283
"nbconvert_exporter": "python",
205284
"pygments_lexer": "ipython3",
206-
"version": "3.8.8"
285+
"version": "3.12.1"
207286
}
208287
},
209288
"nbformat": 4,

0 commit comments

Comments
 (0)