|
83 | 83 | "id": "x9xQXOnRa0MS", |
84 | 84 | "outputId": "64294c78-0769-4728-f781-9204a1aa51e3" |
85 | 85 | }, |
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": [], |
96 | 87 | "source": [ |
97 | 88 | "usd_amount = input (\"Enter the amount in USD: \")\n", |
98 | 89 | "bp_amount = int(usd_amount) *0.82\n", |
|
179 | 170 | }, |
180 | 171 | "outputs": [], |
181 | 172 | "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 | + ] |
182 | 261 | } |
183 | 262 | ], |
184 | 263 | "metadata": { |
|
203 | 282 | "name": "python", |
204 | 283 | "nbconvert_exporter": "python", |
205 | 284 | "pygments_lexer": "ipython3", |
206 | | - "version": "3.8.8" |
| 285 | + "version": "3.12.1" |
207 | 286 | } |
208 | 287 | }, |
209 | 288 | "nbformat": 4, |
|
0 commit comments