|
296 | 296 | },
|
297 | 297 | {
|
298 | 298 | "cell_type": "code",
|
299 |
| - "execution_count": 68, |
| 299 | + "execution_count": 1, |
300 | 300 | "metadata": {},
|
301 | 301 | "outputs": [
|
302 | 302 | {
|
303 | 303 | "name": "stdout",
|
304 | 304 | "output_type": "stream",
|
305 | 305 | "text": [
|
306 |
| - "Temp in Fahrenheir: 89.6 F\n" |
| 306 | + "Temp in Fahrenheir: 95.0 F\n" |
307 | 307 | ]
|
308 | 308 | }
|
309 | 309 | ],
|
|
318 | 318 | "temp(temperature)"
|
319 | 319 | ]
|
320 | 320 | },
|
| 321 | + { |
| 322 | + "cell_type": "code", |
| 323 | + "execution_count": 6, |
| 324 | + "metadata": {}, |
| 325 | + "outputs": [ |
| 326 | + { |
| 327 | + "name": "stdout", |
| 328 | + "output_type": "stream", |
| 329 | + "text": [ |
| 330 | + "52 is the maximum number.\n" |
| 331 | + ] |
| 332 | + } |
| 333 | + ], |
| 334 | + "source": [ |
| 335 | + "# find maximum of 3 numbers\n", |
| 336 | + "def maximum(a,b,c):\n", |
| 337 | + " if(a>=b and a>=c):\n", |
| 338 | + " return a\n", |
| 339 | + " elif(b>=a and b>=c):\n", |
| 340 | + " return b\n", |
| 341 | + " else:\n", |
| 342 | + " return c\n", |
| 343 | + "\n", |
| 344 | + "a=int(input('enter first number: '))\n", |
| 345 | + "b=int(input('enter second number: '))\n", |
| 346 | + "c=int(input('enter third number: '))\n", |
| 347 | + "res=maximum(a,b,c)\n", |
| 348 | + "print(res,\"is the maximum number.\")\n" |
| 349 | + ] |
| 350 | + }, |
| 351 | + { |
| 352 | + "cell_type": "code", |
| 353 | + "execution_count": 9, |
| 354 | + "metadata": {}, |
| 355 | + "outputs": [ |
| 356 | + { |
| 357 | + "name": "stdout", |
| 358 | + "output_type": "stream", |
| 359 | + "text": [ |
| 360 | + "Factorial of 6 is : 720\n" |
| 361 | + ] |
| 362 | + } |
| 363 | + ], |
| 364 | + "source": [ |
| 365 | + "# program to calculate factorial\n", |
| 366 | + "def fact(num):\n", |
| 367 | + " a=1\n", |
| 368 | + " for i in range(1,num+1):\n", |
| 369 | + " a=a*i\n", |
| 370 | + " print('Factorial of ',num,'is : ',a)\n", |
| 371 | + "\n", |
| 372 | + "num=int(input('enter the number: '))\n", |
| 373 | + "fact(num)" |
| 374 | + ] |
| 375 | + }, |
| 376 | + { |
| 377 | + "cell_type": "code", |
| 378 | + "execution_count": 28, |
| 379 | + "metadata": {}, |
| 380 | + "outputs": [ |
| 381 | + { |
| 382 | + "name": "stdout", |
| 383 | + "output_type": "stream", |
| 384 | + "text": [ |
| 385 | + "reveresed string: elppa\n" |
| 386 | + ] |
| 387 | + } |
| 388 | + ], |
| 389 | + "source": [ |
| 390 | + "# reverse of a string\n", |
| 391 | + "def reverse(a):\n", |
| 392 | + " b=''\n", |
| 393 | + " l=len(a)\n", |
| 394 | + " for i in range(-1,-(l+1),-1):\n", |
| 395 | + " b=b+a[i]\n", |
| 396 | + " print(\"reveresed string: \",b)\n", |
| 397 | + "\n", |
| 398 | + "\n", |
| 399 | + "a=input('enter the string: ')\n", |
| 400 | + "reverse(a)" |
| 401 | + ] |
| 402 | + }, |
| 403 | + { |
| 404 | + "cell_type": "code", |
| 405 | + "execution_count": 38, |
| 406 | + "metadata": {}, |
| 407 | + "outputs": [ |
| 408 | + { |
| 409 | + "name": "stdout", |
| 410 | + "output_type": "stream", |
| 411 | + "text": [ |
| 412 | + "EducAtiOn has 5 Vowels.\n" |
| 413 | + ] |
| 414 | + } |
| 415 | + ], |
| 416 | + "source": [ |
| 417 | + "# to count vowels in a string\n", |
| 418 | + "def vowel(s):\n", |
| 419 | + " c=0\n", |
| 420 | + " for i in s:\n", |
| 421 | + " if i in ('a','e','i','o','u','A','E','I','O','U'):\n", |
| 422 | + " c+=1\n", |
| 423 | + " else:\n", |
| 424 | + " continue\n", |
| 425 | + " return c\n", |
| 426 | + "\n", |
| 427 | + "st=input('enter a string: ')\n", |
| 428 | + "res=vowel(st)\n", |
| 429 | + "print(st,'has ',res,'Vowels.')\n" |
| 430 | + ] |
| 431 | + }, |
| 432 | + { |
| 433 | + "cell_type": "code", |
| 434 | + "execution_count": 40, |
| 435 | + "metadata": {}, |
| 436 | + "outputs": [ |
| 437 | + { |
| 438 | + "name": "stdout", |
| 439 | + "output_type": "stream", |
| 440 | + "text": [ |
| 441 | + "BMI is : 22.650586999334745\n" |
| 442 | + ] |
| 443 | + } |
| 444 | + ], |
| 445 | + "source": [ |
| 446 | + "# to calculate BMI\n", |
| 447 | + "def bmi(wt,ht):\n", |
| 448 | + " res=(wt/(ht*ht))\n", |
| 449 | + " return res\n", |
| 450 | + "weight=float(input('enter weight in Kg: '))\n", |
| 451 | + "height= float(input('enter height in Metres: '))\n", |
| 452 | + "result=bmi(weight,height)\n", |
| 453 | + "print('BMI is : ', result)" |
| 454 | + ] |
| 455 | + }, |
321 | 456 | {
|
322 | 457 | "cell_type": "markdown",
|
323 | 458 | "metadata": {},
|
|
0 commit comments