|
7 | 7 | "metadata": {}, |
8 | 8 | "outputs": [], |
9 | 9 | "source": [ |
10 | | - "# Question 1 \n", |
| 10 | + "# Question 1\n", |
11 | 11 | "\n", |
12 | 12 | "pi = 3.14\n", |
13 | 13 | "r = 5" |
|
20 | 20 | "metadata": {}, |
21 | 21 | "outputs": [], |
22 | 22 | "source": [ |
23 | | - "\n", |
24 | | - "vol_sphere = 4/3*pi*r*r*r" |
| 23 | + "vol_sphere = 4 / 3 * pi * r * r * r" |
25 | 24 | ] |
26 | 25 | }, |
27 | 26 | { |
|
52 | 51 | "metadata": {}, |
53 | 52 | "outputs": [], |
54 | 53 | "source": [ |
55 | | - "#Question 2\n", |
| 54 | + "# Question 2\n", |
56 | 55 | "\n", |
57 | 56 | "cover_price = 24.95\n", |
58 | 57 | "discount = 0.4\n", |
59 | 58 | "\n", |
60 | 59 | "shipping_cost_first_copy = 3\n", |
61 | 60 | "shipping_cost_next_copy = 0.75\n", |
62 | 61 | "\n", |
63 | | - "quantity = 60\n", |
64 | | - "\n" |
| 62 | + "quantity = 60" |
65 | 63 | ] |
66 | 64 | }, |
67 | 65 | { |
|
135 | 133 | } |
136 | 134 | ], |
137 | 135 | "source": [ |
138 | | - "#Question 3\n", |
| 136 | + "# Question 3\n", |
139 | 137 | "# Start time\n", |
140 | 138 | "start_hour = 6\n", |
141 | 139 | "start_minute = 52\n", |
|
144 | 142 | "start_seconds = (start_hour * 60 + start_minute) * 60\n", |
145 | 143 | "\n", |
146 | 144 | "# 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", |
| 145 | + "easy_pace_seconds = 8 * 60 + 15 # 1 mile at easy pace\n", |
| 146 | + "tempo_pace_seconds = 7 * 60 + 12 # per mile at tempo pace\n", |
149 | 147 | "\n", |
150 | 148 | "# Total run time in seconds\n", |
151 | 149 | "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", |
| 150 | + " easy_pace_seconds # first easy mile\n", |
| 151 | + " + 3 * tempo_pace_seconds # three tempo miles\n", |
| 152 | + " + easy_pace_seconds # final easy mile\n", |
155 | 153 | ")\n", |
156 | 154 | "\n", |
157 | 155 | "# End time in seconds\n", |
|
163 | 161 | "end_second = end_seconds % 60\n", |
164 | 162 | "\n", |
165 | 163 | "# Display result\n", |
166 | | - "print(f\"Home for breakfast at: {int(end_hour)}:{int(end_minute):02d}:{int(end_second):02d}\")\n" |
| 164 | + "print(\n", |
| 165 | + " f\"Home for breakfast at: {int(end_hour)}:{int(end_minute):02d}:{int(end_second):02d}\"\n", |
| 166 | + ")" |
167 | 167 | ] |
168 | 168 | }, |
169 | 169 | { |
|
181 | 181 | } |
182 | 182 | ], |
183 | 183 | "source": [ |
184 | | - "#Question 4\n", |
| 184 | + "# Question 4\n", |
185 | 185 | "\n", |
186 | 186 | "basic_salary = 5000\n", |
187 | 187 | "\n", |
|
191 | 191 | "\n", |
192 | 192 | "gross_salary = basic_salary + dearness_allowance + hra\n", |
193 | 193 | "\n", |
194 | | - "print('Gross Salary of Ram: ',gross_salary)" |
| 194 | + "print(\"Gross Salary of Ram: \", gross_salary)" |
195 | 195 | ] |
196 | 196 | }, |
197 | 197 | { |
|
213 | 213 | } |
214 | 214 | ], |
215 | 215 | "source": [ |
216 | | - "#Question 5\n", |
| 216 | + "# Question 5\n", |
217 | 217 | "\n", |
218 | 218 | "km = 100 # Example distance\n", |
219 | 219 | "meters = km * 1000\n", |
|
222 | 222 | "feet = inches / 12\n", |
223 | 223 | "yards = feet / 3\n", |
224 | 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" |
| 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)" |
230 | 230 | ] |
231 | 231 | }, |
232 | 232 | { |
|
244 | 244 | } |
245 | 245 | ], |
246 | 246 | "source": [ |
247 | | - "#Question 6\n", |
| 247 | + "# Question 6\n", |
248 | 248 | "\n", |
249 | | - "fahrenheit = 98.6 \n", |
| 249 | + "fahrenheit = 98.6\n", |
250 | 250 | "celsius = (fahrenheit - 32) * 5 / 9\n", |
251 | | - "print(f\"Temperature: {fahrenheit}°F = {celsius:.2f}°C\")\n" |
| 251 | + "print(f\"Temperature: {fahrenheit}°F = {celsius:.2f}°C\")" |
252 | 252 | ] |
253 | 253 | }, |
254 | 254 | { |
|
258 | 258 | "metadata": {}, |
259 | 259 | "outputs": [], |
260 | 260 | "source": [ |
261 | | - "#Question 7 \n", |
| 261 | + "# Question 7\n", |
262 | 262 | "\n", |
263 | 263 | "\n", |
264 | | - "start_hour = 12 \n", |
| 264 | + "start_hour = 12\n", |
265 | 265 | "start_min = 17\n", |
266 | 266 | "\n", |
267 | 267 | "time_in_min = start_hour * 60 + start_min\n", |
|
330 | 330 | } |
331 | 331 | ], |
332 | 332 | "source": [ |
333 | | - "print(f'If the event starts at {start_hour}:{start_min}, will end at {time_in_hours}:{time_in_mins}')" |
| 333 | + "print(\n", |
| 334 | + " f\"If the event starts at {start_hour}:{start_min}, will end at {time_in_hours}:{time_in_mins}\"\n", |
| 335 | + ")" |
334 | 336 | ] |
335 | 337 | }, |
336 | 338 | { |
|
0 commit comments