|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "id": "b5aa5788-182d-4ea2-b77c-170561d4568c", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "# Question 1 \n", |
| 11 | + "\n", |
| 12 | + "pi = 3.14\n", |
| 13 | + "r = 5" |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "code", |
| 18 | + "execution_count": 2, |
| 19 | + "id": "81c672ca-98c8-486f-9ad3-49f87f358a40", |
| 20 | + "metadata": {}, |
| 21 | + "outputs": [], |
| 22 | + "source": [ |
| 23 | + "\n", |
| 24 | + "vol_sphere = 4/3*pi*r*r*r" |
| 25 | + ] |
| 26 | + }, |
| 27 | + { |
| 28 | + "cell_type": "code", |
| 29 | + "execution_count": 3, |
| 30 | + "id": "205847dc-9575-43c8-beee-99239e3550b0", |
| 31 | + "metadata": {}, |
| 32 | + "outputs": [ |
| 33 | + { |
| 34 | + "data": { |
| 35 | + "text/plain": [ |
| 36 | + "523.3333333333334" |
| 37 | + ] |
| 38 | + }, |
| 39 | + "execution_count": 3, |
| 40 | + "metadata": {}, |
| 41 | + "output_type": "execute_result" |
| 42 | + } |
| 43 | + ], |
| 44 | + "source": [ |
| 45 | + "vol_sphere" |
| 46 | + ] |
| 47 | + }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": 4, |
| 51 | + "id": "625bf11e-43d9-4fda-8390-758d9e0ef126", |
| 52 | + "metadata": {}, |
| 53 | + "outputs": [], |
| 54 | + "source": [ |
| 55 | + "#Question 2\n", |
| 56 | + "\n", |
| 57 | + "cover_price = 24.95\n", |
| 58 | + "discount = 0.4\n", |
| 59 | + "\n", |
| 60 | + "shipping_cost_first_copy = 3\n", |
| 61 | + "shipping_cost_next_copy = 0.75\n", |
| 62 | + "\n", |
| 63 | + "quantity = 60\n", |
| 64 | + "\n" |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "code", |
| 69 | + "execution_count": 5, |
| 70 | + "id": "b107a436-98e9-4e29-ad9e-bc3bbf33ce7a", |
| 71 | + "metadata": {}, |
| 72 | + "outputs": [], |
| 73 | + "source": [ |
| 74 | + "discounted_price = cover_price - (cover_price * discount)\n", |
| 75 | + "shipping_cost = shipping_cost_first_copy + (59 * shipping_cost_next_copy)\n", |
| 76 | + "\n", |
| 77 | + "total_cost = (discounted_price * 60) + shipping_cost" |
| 78 | + ] |
| 79 | + }, |
| 80 | + { |
| 81 | + "cell_type": "code", |
| 82 | + "execution_count": 6, |
| 83 | + "id": "965b82fa-9b4c-45b3-8ae1-b775af4bdc03", |
| 84 | + "metadata": {}, |
| 85 | + "outputs": [ |
| 86 | + { |
| 87 | + "data": { |
| 88 | + "text/plain": [ |
| 89 | + "945.4499999999999" |
| 90 | + ] |
| 91 | + }, |
| 92 | + "execution_count": 6, |
| 93 | + "metadata": {}, |
| 94 | + "output_type": "execute_result" |
| 95 | + } |
| 96 | + ], |
| 97 | + "source": [ |
| 98 | + "total_cost" |
| 99 | + ] |
| 100 | + }, |
| 101 | + { |
| 102 | + "cell_type": "code", |
| 103 | + "execution_count": 7, |
| 104 | + "id": "6e46ebc9-5448-4d28-a736-759e8421ab26", |
| 105 | + "metadata": {}, |
| 106 | + "outputs": [ |
| 107 | + { |
| 108 | + "data": { |
| 109 | + "text/plain": [ |
| 110 | + "23" |
| 111 | + ] |
| 112 | + }, |
| 113 | + "execution_count": 7, |
| 114 | + "metadata": {}, |
| 115 | + "output_type": "execute_result" |
| 116 | + } |
| 117 | + ], |
| 118 | + "source": [ |
| 119 | + "easy_pace = 8 + 15 % 60\n", |
| 120 | + "easy_pace" |
| 121 | + ] |
| 122 | + }, |
| 123 | + { |
| 124 | + "cell_type": "code", |
| 125 | + "execution_count": 8, |
| 126 | + "id": "5a66ecc3-390c-44db-a2c9-6b4d6995a2cb", |
| 127 | + "metadata": {}, |
| 128 | + "outputs": [ |
| 129 | + { |
| 130 | + "name": "stdout", |
| 131 | + "output_type": "stream", |
| 132 | + "text": [ |
| 133 | + "Home for breakfast at: 7:30:06\n" |
| 134 | + ] |
| 135 | + } |
| 136 | + ], |
| 137 | + "source": [ |
| 138 | + "#Question 3\n", |
| 139 | + "# Start time\n", |
| 140 | + "start_hour = 6\n", |
| 141 | + "start_minute = 52\n", |
| 142 | + "\n", |
| 143 | + "# Convert start time to total seconds\n", |
| 144 | + "start_seconds = (start_hour * 60 + start_minute) * 60\n", |
| 145 | + "\n", |
| 146 | + "# Pace times in seconds\n", |
| 147 | + "easy_pace_seconds = 8 * 60 + 15 # 1 mile at easy pace\n", |
| 148 | + "tempo_pace_seconds = 7 * 60 + 12 # per mile at tempo pace\n", |
| 149 | + "\n", |
| 150 | + "# Total run time in seconds\n", |
| 151 | + "total_run_seconds = (\n", |
| 152 | + " easy_pace_seconds + # first easy mile\n", |
| 153 | + " 3 * tempo_pace_seconds + # three tempo miles\n", |
| 154 | + " easy_pace_seconds # final easy mile\n", |
| 155 | + ")\n", |
| 156 | + "\n", |
| 157 | + "# End time in seconds\n", |
| 158 | + "end_seconds = start_seconds + total_run_seconds\n", |
| 159 | + "\n", |
| 160 | + "# Convert back to hours, minutes, seconds\n", |
| 161 | + "end_hour = end_seconds // 3600\n", |
| 162 | + "end_minute = (end_seconds % 3600) // 60\n", |
| 163 | + "end_second = end_seconds % 60\n", |
| 164 | + "\n", |
| 165 | + "# Display result\n", |
| 166 | + "print(f\"Home for breakfast at: {int(end_hour)}:{int(end_minute):02d}:{int(end_second):02d}\")\n" |
| 167 | + ] |
| 168 | + }, |
| 169 | + { |
| 170 | + "cell_type": "code", |
| 171 | + "execution_count": 10, |
| 172 | + "id": "7f606f1a-16b1-40c9-a206-2dd9468ad00f", |
| 173 | + "metadata": {}, |
| 174 | + "outputs": [ |
| 175 | + { |
| 176 | + "name": "stdout", |
| 177 | + "output_type": "stream", |
| 178 | + "text": [ |
| 179 | + "Gross Salary of Ram: 8000.0\n" |
| 180 | + ] |
| 181 | + } |
| 182 | + ], |
| 183 | + "source": [ |
| 184 | + "#Question 4\n", |
| 185 | + "\n", |
| 186 | + "basic_salary = 5000\n", |
| 187 | + "\n", |
| 188 | + "dearness_allowance = 0.4 * basic_salary\n", |
| 189 | + "\n", |
| 190 | + "hra = 0.2 * basic_salary\n", |
| 191 | + "\n", |
| 192 | + "gross_salary = basic_salary + dearness_allowance + hra\n", |
| 193 | + "\n", |
| 194 | + "print('Gross Salary of Ram: ',gross_salary)" |
| 195 | + ] |
| 196 | + }, |
| 197 | + { |
| 198 | + "cell_type": "code", |
| 199 | + "execution_count": 11, |
| 200 | + "id": "88a403cc-2919-416d-aff4-7a28625e59be", |
| 201 | + "metadata": {}, |
| 202 | + "outputs": [ |
| 203 | + { |
| 204 | + "name": "stdout", |
| 205 | + "output_type": "stream", |
| 206 | + "text": [ |
| 207 | + "100 km in meters: 100000\n", |
| 208 | + "In centimeters: 10000000\n", |
| 209 | + "In inches: 3937007.874015748\n", |
| 210 | + "In feet: 328083.9895013123\n", |
| 211 | + "In yards: 109361.32983377077\n" |
| 212 | + ] |
| 213 | + } |
| 214 | + ], |
| 215 | + "source": [ |
| 216 | + "#Question 5\n", |
| 217 | + "\n", |
| 218 | + "km = 100 # Example distance\n", |
| 219 | + "meters = km * 1000\n", |
| 220 | + "centimeters = meters * 100\n", |
| 221 | + "inches = centimeters / 2.54\n", |
| 222 | + "feet = inches / 12\n", |
| 223 | + "yards = feet / 3\n", |
| 224 | + "\n", |
| 225 | + "print(km, 'km in meters: ',meters)\n", |
| 226 | + "print(\"In centimeters:\",centimeters)\n", |
| 227 | + "print(\"In inches: \",inches)\n", |
| 228 | + "print(\"In feet: \",feet)\n", |
| 229 | + "print(\"In yards: \",yards)\n" |
| 230 | + ] |
| 231 | + }, |
| 232 | + { |
| 233 | + "cell_type": "code", |
| 234 | + "execution_count": 12, |
| 235 | + "id": "6896b1f4-806d-40ba-aa07-e09244327a98", |
| 236 | + "metadata": {}, |
| 237 | + "outputs": [ |
| 238 | + { |
| 239 | + "name": "stdout", |
| 240 | + "output_type": "stream", |
| 241 | + "text": [ |
| 242 | + "Temperature: 98.6°F = 37.00°C\n" |
| 243 | + ] |
| 244 | + } |
| 245 | + ], |
| 246 | + "source": [ |
| 247 | + "#Question 6\n", |
| 248 | + "\n", |
| 249 | + "fahrenheit = 98.6 \n", |
| 250 | + "celsius = (fahrenheit - 32) * 5 / 9\n", |
| 251 | + "print(f\"Temperature: {fahrenheit}°F = {celsius:.2f}°C\")\n" |
| 252 | + ] |
| 253 | + }, |
| 254 | + { |
| 255 | + "cell_type": "code", |
| 256 | + "execution_count": 13, |
| 257 | + "id": "bdb1b5ed-fdf1-4eac-8b9f-e32b6530eaa3", |
| 258 | + "metadata": {}, |
| 259 | + "outputs": [], |
| 260 | + "source": [ |
| 261 | + "#Question 7 \n", |
| 262 | + "\n", |
| 263 | + "\n", |
| 264 | + "start_hour = 12 \n", |
| 265 | + "start_min = 17\n", |
| 266 | + "\n", |
| 267 | + "time_in_min = start_hour * 60 + start_min\n", |
| 268 | + "\n", |
| 269 | + "time_to_add = 59\n", |
| 270 | + "\n", |
| 271 | + "total_time_in_mins = time_in_min + time_to_add\n", |
| 272 | + "time_in_hours = total_time_in_mins // 60\n", |
| 273 | + "time_in_mins = total_time_in_mins % 60" |
| 274 | + ] |
| 275 | + }, |
| 276 | + { |
| 277 | + "cell_type": "code", |
| 278 | + "execution_count": 14, |
| 279 | + "id": "b74805e7-b9f9-4d69-b496-e98c9fc1675b", |
| 280 | + "metadata": {}, |
| 281 | + "outputs": [ |
| 282 | + { |
| 283 | + "data": { |
| 284 | + "text/plain": [ |
| 285 | + "13" |
| 286 | + ] |
| 287 | + }, |
| 288 | + "execution_count": 14, |
| 289 | + "metadata": {}, |
| 290 | + "output_type": "execute_result" |
| 291 | + } |
| 292 | + ], |
| 293 | + "source": [ |
| 294 | + "time_in_hours" |
| 295 | + ] |
| 296 | + }, |
| 297 | + { |
| 298 | + "cell_type": "code", |
| 299 | + "execution_count": 15, |
| 300 | + "id": "2199d7ea-21bf-4861-99a7-83a7253b47b0", |
| 301 | + "metadata": {}, |
| 302 | + "outputs": [ |
| 303 | + { |
| 304 | + "data": { |
| 305 | + "text/plain": [ |
| 306 | + "16" |
| 307 | + ] |
| 308 | + }, |
| 309 | + "execution_count": 15, |
| 310 | + "metadata": {}, |
| 311 | + "output_type": "execute_result" |
| 312 | + } |
| 313 | + ], |
| 314 | + "source": [ |
| 315 | + "time_in_mins" |
| 316 | + ] |
| 317 | + }, |
| 318 | + { |
| 319 | + "cell_type": "code", |
| 320 | + "execution_count": 16, |
| 321 | + "id": "8fc98a28-09e9-4852-b8da-ff67f278d2a5", |
| 322 | + "metadata": {}, |
| 323 | + "outputs": [ |
| 324 | + { |
| 325 | + "name": "stdout", |
| 326 | + "output_type": "stream", |
| 327 | + "text": [ |
| 328 | + "If the event starts at 12:17, will end at 13:16\n" |
| 329 | + ] |
| 330 | + } |
| 331 | + ], |
| 332 | + "source": [ |
| 333 | + "print(f'If the event starts at {start_hour}:{start_min}, will end at {time_in_hours}:{time_in_mins}')" |
| 334 | + ] |
| 335 | + }, |
| 336 | + { |
| 337 | + "cell_type": "code", |
| 338 | + "execution_count": null, |
| 339 | + "id": "6c8a8adc-bdc8-4d67-af41-f0152f8d40f7", |
| 340 | + "metadata": {}, |
| 341 | + "outputs": [], |
| 342 | + "source": [] |
| 343 | + } |
| 344 | + ], |
| 345 | + "metadata": { |
| 346 | + "kernelspec": { |
| 347 | + "display_name": "Python [conda env:base] *", |
| 348 | + "language": "python", |
| 349 | + "name": "conda-base-py" |
| 350 | + }, |
| 351 | + "language_info": { |
| 352 | + "codemirror_mode": { |
| 353 | + "name": "ipython", |
| 354 | + "version": 3 |
| 355 | + }, |
| 356 | + "file_extension": ".py", |
| 357 | + "mimetype": "text/x-python", |
| 358 | + "name": "python", |
| 359 | + "nbconvert_exporter": "python", |
| 360 | + "pygments_lexer": "ipython3", |
| 361 | + "version": "3.13.5" |
| 362 | + } |
| 363 | + }, |
| 364 | + "nbformat": 4, |
| 365 | + "nbformat_minor": 5 |
| 366 | +} |
0 commit comments