Spaces:
No application file
No application file
File size: 48,840 Bytes
5d07f20 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "2224f9a4-403e-4ec9-81c2-4078bd9403cc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'str'>\n",
"['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']\n"
]
}
],
"source": [
"a = \"Pakistan zindabad!\"\n",
"print(type(a))\n",
"print(dir(a)) # dir return all methods and attribute"
]
},
{
"cell_type": "markdown",
"id": "db8d32d8-5390-45d5-9147-ab1467471a02",
"metadata": {},
"source": [
"All **Methods**/function, **attribtues**/properties/fields of string\n",
"* `method_name()`\n",
"* `attribute_name`\n",
"\n",
"* How we can call methods or attribute\n",
" * `object_name.method_name()`\n",
" * `object_name.attribute_name` "
]
},
{
"cell_type": "raw",
"id": "0edf4cea-3792-4418-ad9f-512a03ed6406",
"metadata": {},
"source": [
"'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4fbb83de-957f-4400-87cb-b2f2a961000e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Pakistan zinda bad!\n",
"we love our country.\n"
]
}
],
"source": [
"text = \"\"\"Pakistan zInda BAd!\n",
"we Love OuR country.\"\"\"\n",
"\n",
"print(text.capitalize())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "aa4a435e-5b26-461f-8f0e-ef5645b6243e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pakistan zinda bad!\n",
"we love our country.\n"
]
}
],
"source": [
"text = \"\"\"Pakistan zInda BAd!\n",
"we Love OuR country.\"\"\"\n",
"\n",
"print(text.casefold())"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "4f19282e-de10-4c92-b7e2-a81fac3b8233",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"14\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"print(len(name)) # len global function"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "58f0b8c4-e5f6-4b14-bfc2-7a197a9799e4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"14\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"print(name.__len__()) # method"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "1f5a4a00-5e19-4e2b-b20d-a8f94fb7851c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' Muhammad Qasim '"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"name.center(20)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "9379d170-112c-41a6-9e01-4a4e4e180da5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"print(name.count(\"a\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4dec346e-9262-499a-b422-b342e1c8f616",
"metadata": {},
"outputs": [],
"source": [
"name = \"Muhammad Qasim\"\n",
"print(name.count(\"a\"))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "1a511ad5-e0b5-42c2-a5ed-bc776445c6ab",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'qasim'"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'abc'\n",
"'123'\n",
"'qasim'"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "17268b5d-8d31-4467-90b3-b516f7e51632",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"name = \"Muhammad Qasim is teaching AI at NE\"\n",
"print(name.count(\"Qasim\"))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "292b7c2e-9246-4c1f-994d-af07169b68c3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"\n",
"name.count(\"m\") + name.count(\"a\") + name.count(\"M\") + name.count(\"A\")"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "bc7bbe09-005e-4d89-82b5-e845d2fb5edb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"muhammad qasim\n",
"4 3\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\" # step1 Muhammad Qasim\n",
"name = name.casefold()#step2 -> muhammad qasim\n",
"print(name)# step3->display\n",
"\n",
"# m=4 a=3\n",
"print(name.count(\"m\") , name.count(\"a\"))"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "b586aee1-69e4-42bf-9bd0-5cbe853acca3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"muhammad qasim\n",
"<class 'int'>\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\" # step1 Muhammad Qasim\n",
"name = name.casefold()#step2 -> muhammad qasim\n",
"print(name)# step3->display\n",
"\n",
"# m=4 a=3\n",
"m1 = name.count(\"m\") # count method always return int value\n",
"a1 = name.count(\"a\")\n",
"\n",
"print(type(m1))\n"
]
},
{
"cell_type": "markdown",
"id": "a647b3d3-b9fe-4ba5-a234-cfd61ef73b6f",
"metadata": {},
"source": [
"اب دع ف\n",
"https://www.w3schools.com/python/ref_string_encode.asp"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "73b3a57a-017a-4d47-9865-3cf7197c47aa",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"b'My name is St\\xc3\\xa5le'\n"
]
}
],
"source": [
"txt = \"My name is Ståle\"\n",
"\n",
"x = txt.encode()\n",
"\n",
"print(x)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "b927183b-5512-47ca-a3ee-0ddba5a53c71",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"b'My name is St\\\\xe5le'\n",
"b'My name is Stle'\n",
"b'My name is St\\\\N{LATIN SMALL LETTER A WITH RING ABOVE}le'\n",
"b'My name is St?le'\n",
"b'My name is Ståle'\n"
]
}
],
"source": [
"txt = \"My name is Ståle\"\n",
"\n",
"print(txt.encode(encoding=\"ascii\",errors=\"backslashreplace\"))\n",
"print(txt.encode(encoding=\"ascii\",errors=\"ignore\"))\n",
"print(txt.encode(encoding=\"ascii\",errors=\"namereplace\"))\n",
"print(txt.encode(encoding=\"ascii\",errors=\"replace\"))\n",
"print(txt.encode(encoding=\"ascii\",errors=\"xmlcharrefreplace\"))\n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "1c751779-0c99-496d-8f5d-b0b02c5506a3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"True\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"print(name.endswith(\"m\"))\n",
"print(name.endswith(\"sim\"))"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "834ea1f9-75ab-4ff4-893f-574085db4b48",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"False\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"print(name.startswith(\"M\"))\n",
"print(name.startswith(\"sim\"))"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "aa13d183-6560-4572-8080-a0c6b36fc76a",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"start with Mu\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"False\n"
]
}
],
"source": [
"name = \"Muhammad Qasim\"\n",
"\n",
"search = input(\"start with \")\n",
"\n",
"print(name.startswith(search))\n",
"print(name.startswith(\"sim\"))"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "2195d531-5325-410b-b2f3-c854766a31d1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"NED University\n",
"Batch 5\n",
"Class:\t Python\n",
"Name:\tMuhammad Qasim\n",
"Father's Name:\tMuhammad Aslam\n",
"\n"
]
}
],
"source": [
"card = \"\"\"\n",
"NED University\n",
"Batch 5\n",
"Class:\\t Python\n",
"Name:\\tMuhammad Qasim\n",
"Father's Name:\\tMuhammad Aslam\n",
"\"\"\"\n",
"\n",
"print(card)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "50847f71-7b8c-4c86-a8ad-b702c0e0718c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"NED University\n",
"Batch 5\n",
"Class: Python\n",
"Name: Muhammad Qasim\n",
"Father's Name: Muhammad Aslam\n",
"\n"
]
}
],
"source": [
"card = \"\"\"\n",
"NED University\n",
"Batch 5\n",
"Class:\\tPython\n",
"Name:\\tMuhammad Qasim\n",
"Father's Name:\\tMuhammad Aslam\n",
"\"\"\"\n",
"\n",
"print(card.expandtabs(30))"
]
},
{
"cell_type": "markdown",
"id": "e9bec548-8b71-43a4-adaa-0982e17fdc84",
"metadata": {},
"source": [
"Help\n",
"* help(function)\n",
"* help(object_name.method)\n",
"* function?\n",
"* function??\n",
"* ?function\n",
"* ??function\n",
"* function(shift+press_tab_button)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "0e747df7-53c9-45ec-a2ae-55dbda2170f3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on built-in function print in module builtins:\n",
"\n",
"print(...)\n",
" print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n",
" \n",
" Prints the values to a stream, or to sys.stdout by default.\n",
" Optional keyword arguments:\n",
" file: a file-like object (stream); defaults to the current sys.stdout.\n",
" sep: string inserted between values, default a space.\n",
" end: string appended after the last value, default a newline.\n",
" flush: whether to forcibly flush the stream.\n",
"\n"
]
}
],
"source": [
"help(print)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "5303f4b2-8a06-419a-9849-4ac9f4c17c1e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mDocstring:\u001b[0m\n",
"print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n",
"\n",
"Prints the values to a stream, or to sys.stdout by default.\n",
"Optional keyword arguments:\n",
"file: a file-like object (stream); defaults to the current sys.stdout.\n",
"sep: string inserted between values, default a space.\n",
"end: string appended after the last value, default a newline.\n",
"flush: whether to forcibly flush the stream.\n",
"\u001b[0;31mType:\u001b[0m builtin_function_or_method"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"print??"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "6c50c4ec-9987-4dc8-a65a-b5ec4a16236e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mDocstring:\u001b[0m\n",
"print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n",
"\n",
"Prints the values to a stream, or to sys.stdout by default.\n",
"Optional keyword arguments:\n",
"file: a file-like object (stream); defaults to the current sys.stdout.\n",
"sep: string inserted between values, default a space.\n",
"end: string appended after the last value, default a newline.\n",
"flush: whether to forcibly flush the stream.\n",
"\u001b[0;31mType:\u001b[0m builtin_function_or_method"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"??print"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "143fbcb2-c9e2-468f-9a7f-50e851258858",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mSignature:\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m Return a copy of the string converted to lowercase.\n",
"\u001b[0;31mType:\u001b[0m builtin_function_or_method"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"name = \"MuHaMmad QaSiM\"\n",
"\n",
"?name.lower"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "0518254a-d8f1-447e-a22f-675f2f1b051a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'muhammad qasim'"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \"MuHaMmad QaSiM\"\n",
"name.lower()"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "83d2ee6b-d1e7-4b5d-ad06-1eaf97fc9dda",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [
"a = 3 and 2\n",
"print(a)"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "436cdab6-8973-473c-ba48-5f1d69c9022e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Muhammad Qasim '"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \" Muhammad Qasim \"\n",
"name.lstrip()"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "2f6312d8-ba31-4d53-9f89-3cdea2eeda87",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' Muhammad Qasim'"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \" Muhammad Qasim \"\n",
"name.rstrip()"
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "786b0228-7dce-4afe-95ce-101bdafc6f00",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Muhammad Qasim'"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \" Muhammad Qasim \"\n",
"name.strip()"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "fc53ea9d-328c-4d07-9b31-fb18ad4b947f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Muhammad Qasim'"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \" Muhammad Qasim \"\n",
"name.strip()"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "3522de31-81e7-488d-a637-1544e79bfded",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Muhammad Aslam Aslam Aslam'"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \"Muhammad Qasim Qasim Qasim\"\n",
"name.replace(\"Qasim\",\"Aslam\")"
]
},
{
"cell_type": "code",
"execution_count": 71,
"id": "66eaa6b0-6281-48e7-92fb-078b35d2f819",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Muhammad Aslam Aslam Aslam'"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \"Muhammad Qasim Qasim Qasim\"\n",
"name.replace(\"Qasim\",\"Aslam\", -1)"
]
},
{
"cell_type": "code",
"execution_count": 62,
"id": "49e25a03-1d54-44bb-b83a-31d880c4b295",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name.index(\"Qasim\")"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "f31db96c-389e-452f-910c-5caeb950cc2f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"21"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name = \"Muhammad Qasim Qasim Qasim\"\n",
"\n",
"name.find(\"Qasim\",16)"
]
},
{
"cell_type": "code",
"execution_count": 64,
"id": "0cf6db9f-8d14-42ba-a691-6f499dfc0071",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name.count(\"Qasim\")"
]
},
{
"cell_type": "markdown",
"id": "0ff3725e-9251-491a-a587-7cb688eb88d9",
"metadata": {},
"source": [
"# Additional Task"
]
},
{
"cell_type": "code",
"execution_count": 85,
"id": "dd12feca-cc68-414c-8db4-f8b442d62983",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"74\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CNIC</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4230139058342</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4210255467543</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4220157915361</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4550466911845</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4210111752498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>69</th>\n",
" <td>4240116015521</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70</th>\n",
" <td>4420651603848</td>\n",
" </tr>\n",
" <tr>\n",
" <th>71</th>\n",
" <td>4220113160602</td>\n",
" </tr>\n",
" <tr>\n",
" <th>72</th>\n",
" <td>4220198486247</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>4220105815527</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>74 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" CNIC\n",
"0 4230139058342\n",
"1 4210255467543\n",
"2 4220157915361\n",
"3 4550466911845\n",
"4 4210111752498\n",
".. ...\n",
"69 4240116015521\n",
"70 4420651603848\n",
"71 4220113160602\n",
"72 4220198486247\n",
"73 4220105815527\n",
"\n",
"[74 rows x 1 columns]"
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"text = \"\"\"\n",
"Team NED Academy12:59 PM\n",
"Sir please start recording pleas\n",
"Iqra Ismail1:01 PM\n",
"no\n",
"Muhammad Abubakar1:01 PM\n",
"sir class end pe assignment ke baray mei thora guide krdejye ga\n",
"Iqra Ismail1:02 PM\n",
"yes\n",
"Altaf Hussain Bakhwani1:04 PM\n",
"yes\n",
"Muhammad Abubakar1:04 PM\n",
"clear hai sir\n",
"Talaal Yousoof1:04 PM\n",
"yes\n",
"Altaf Hussain Bakhwani1:07 PM\n",
"yes, action = method, character = attribute\n",
"Talaal Yousoof1:09 PM\n",
"what was attribute pls?\n",
"Uzma Farogh1:09 PM\n",
"sir some students are trying to join. please let them in\n",
"faranaz keshwani1:12 PM\n",
"how do you record attendance on online classes\n",
"Asfa Tabish1:23 PM\n",
"sir method and attribute repeat krdain pls\n",
"Ahmed Naseem1:25 PM\n",
"Yes, main ne bhi late join kiya hai. It would be helpful if you can revise a bit.\n",
"Ashar Khaliq1:39 PM\n",
"print(name.lower().count(\"m\"))\n",
"Rosh Mirza1:41 PM\n",
"name = \"I love my country \"\n",
"name = name.casefold()\n",
"print(\"y count:\",name.count('y'),\"m count :\",name.count('m'))\n",
"You2:17 PM\n",
"24mrw4t\n",
"Imran Haider2:26 PM\n",
"3130315904511\n",
"Muhammad Abubakar2:26 PM\n",
"42201-1270634-5\n",
"Aamir Pingal2:26 PM\n",
"423012945634\n",
"Talaal Yousoof2:26 PM\n",
"4220158211299\n",
"Ahmed Naseem2:26 PM\n",
"4200066399757\n",
"Muhammad Ovais2:26 PM\n",
"42101-4941-769-5\n",
"Atif Salam2:26 PM\n",
"42201-9446591-3\n",
"Altaf Hussain Bakhwani2:26 PM\n",
"4220105815527\n",
"Feroz Gul2:26 PM\n",
"44204-3335269-3\n",
"Jawwad Khan2:26 PM\n",
"42201-9848624-7\n",
"Mahnoor Shoukat2:26 PM\n",
"4250150754028\n",
"hanfia sattar2:26 PM\n",
"4220151056096\n",
"Hiba Rafiq2:26 PM\n",
"4230185868058\n",
"Sadia Javed2:26 PM\n",
"4220158772002\n",
"Hafsa Imtiaz2:26 PM\n",
"42201-8903447-4\n",
"Fahad Hashmi2:27 PM\n",
"4210180636569\n",
"Iqra Ismail2:27 PM\n",
"4220113160602\n",
"Azeem Khan2:27 PM\n",
"42101-7583355-9\n",
"muhammad usman2:27 PM\n",
"33203-1390549-7\n",
"Owais Saeed2:27 PM\n",
"4210187416487\n",
"Dareer Khalid2:27 PM\n",
"4220103150553\n",
"Tauqir Ahmed2:27 PM\n",
"4220157915361\n",
"asad ahmad2:27 PM\n",
"3130349769793\n",
"FJ2:27 PM\n",
"4210174737043\n",
"Abdul Rehman2:27 PM\n",
"4210113955917\n",
"Danish Siddiquie2:27 PM\n",
"4230174890321\n",
"Huzaifa Aazmi2:27 PM\n",
"42101-4717980-5\n",
"Waqas Khan2:27 PM\n",
"35202-2018037-1\n",
"Memon Nadeemhabib2:27 PM\n",
"4130627627273\n",
"Habib Sufyan2:27 PM\n",
"42101-9546976-1\n",
"waqar saleem2:27 PM\n",
"3740611871985\n",
"Muhammad Umer Farooq2:27 PM\n",
"4250141745875\n",
"Ali Mehdi2:27 PM\n",
"42101-0883203-9\n",
"Taj Ahmed2:27 PM\n",
"42101-5086613-3\n",
"Siyam Ansari2:27 PM\n",
"45504-6691184-5\n",
"Asfa Tabish2:27 PM\n",
"42201-3317436-4\n",
"Gul Zaman Shaikh2:27 PM\n",
"42301-4208474-9\n",
"Gul Zaman\n",
"Rohan Wasim2:27 PM\n",
"4210156852483\n",
"Mahek Ali2:27 PM\n",
"4220119350184\n",
"Irtiqa Khan2:27 PM\n",
"42501-1882684-3\n",
"Hammad Khan2:27 PM\n",
"42201-2206678-9\n",
"mansoor ahmed2:27 PM\n",
"41303-1217008-9\n",
"imran jamil2:27 PM\n",
"42201-2367694-3\n",
"Junaid Khan2:27 PM\n",
"4250118835393\n",
"Saira Shaikh2:27 PM\n",
"4220182635186\n",
"Shariq Bashir2:27 PM\n",
"42101-1743803-7\n",
"Asmat Mehmood2:27 PM\n",
"423018695739\n",
"Raheel Nadeem2:27 PM\n",
"4220114028509\n",
"Saba Ali2:27 PM\n",
"42301-3905834-2\n",
"adeel Zaman2:27 PM\n",
"4240116015521 adeel zaman\n",
"Rosh Mirza2:27 PM\n",
"4420651603848\n",
"Ashar Khaliq2:27 PM\n",
"4200004676915\n",
"syed farman ali shah2:27 PM\n",
"1510203461495\n",
"Haroon Saleem2:27 PM\n",
"4240156992579\n",
"Shakeel Ahmed2:27 PM\n",
"4240119589433\n",
"Syed Usman Ghani2:27 PM\n",
"4210109155877\n",
"Abdul Samad Shaikh2:27 PM\n",
"4210255467543\n",
"Muhammad Saad2:27 PM\n",
"42201-4144981-5\n",
"Vishah Fatima2:27 PM\n",
"4210170628928\n",
"KAMRAN KHATRI2:27 PM\n",
"4230198076489\n",
"Shafaat Ahmed Khan2:27 PM\n",
"42201-3225780-3\n",
"Uzma Farogh2:27 PM\n",
"4210190028920\n",
"Akbar Khan2:27 PM\n",
"4220106865377\n",
"bilal2:28 PM\n",
"4210164911883\n",
"Bilal Khan2:28 PM\n",
"42501-3607843-1\n",
"Abdul Samad Shaikh2:28 PM\n",
"4210184328497\n",
"Xyz2:28 PM\n",
"4210118094301\n",
"Mahpara Badar2:28 PM\n",
"4210111752498\n",
"Hasan Mehdi2:28 PM\n",
"4210144676677\n",
"Imran Khan2:28 PM\n",
"4130498094753\n",
"Jahanzeb Siddiqui2:29 PM\n",
"4210169925379\n",
"Omema Akhtar2:29 PM\n",
"4210151840638 omema Akhtar\n",
"Raniya Khan2:29 PM\n",
"42201-9978093-2\n",
"aqsa akmal2:29 PM\n",
"4220145184200\n",
"Javeed Ahmed2:30 PM\n",
"4220141864935\n",
"Ashar Khaliq2:30 PM\n",
"%d\n",
"faranaz keshwani2:31 PM\n",
"42201-7992036-2\n",
"42201-7992036-2 Faranaz Surani\n",
"Ahmed Naseem2:32 PM\n",
"13 digit\n",
"Saba Ali2:32 PM\n",
"13\n",
"Talaal Yousoof2:32 PM\n",
"13\n",
"Danish Siddiquie2:32 PM\n",
"13\n",
"\"\"\"\n",
"\n",
"import re\n",
"import pandas as pd\n",
"\n",
"text = text.replace(\"-\",\"\")\n",
"\n",
"cnic = re.findall('\\d{13}',text)\n",
"cnic = list(set(cnic))\n",
"print(len(cnic))\n",
"\n",
"df = pd.DataFrame({\"CNIC\":cnic})\n",
"df.to_excel(\"class3_attendance.xlsx\", index=False)\n",
"\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 84,
"id": "7d297e88-9633-4957-a4e0-2d4d06238550",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting openpyxl\n",
" Downloading openpyxl-3.1.2-py2.py3-none-any.whl (249 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m250.0/250.0 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
"\u001b[?25hCollecting et-xmlfile (from openpyxl)\n",
" Downloading et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)\n",
"Installing collected packages: et-xmlfile, openpyxl\n",
"Successfully installed et-xmlfile-1.1.0 openpyxl-3.1.2\n"
]
}
],
"source": [
"!pip install openpyxl"
]
},
{
"cell_type": "code",
"execution_count": 99,
"id": "6bb5033a-4dcc-475b-9be8-8b8e80ea4a77",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Team NED Academy1',\n",
" 'Iqra Ismail',\n",
" 'Muhammad Abubakar',\n",
" 'Iqra Ismail',\n",
" 'Altaf Hussain Bakhwani',\n",
" 'Muhammad Abubakar',\n",
" 'Talaal Yousoof',\n",
" 'Altaf Hussain Bakhwani',\n",
" 'Talaal Yousoof',\n",
" 'Uzma Farogh',\n",
" 'faranaz keshwani',\n",
" 'Asfa Tabish',\n",
" 'Ahmed Naseem',\n",
" 'Ashar Khaliq',\n",
" 'Rosh Mirza',\n",
" 'You',\n",
" 'Imran Haider',\n",
" 'Muhammad Abubakar',\n",
" 'Aamir Pingal',\n",
" 'Talaal Yousoof',\n",
" 'Ahmed Naseem',\n",
" 'Muhammad Ovais',\n",
" 'Atif Salam',\n",
" 'Altaf Hussain Bakhwani',\n",
" 'Feroz Gul',\n",
" 'Jawwad Khan',\n",
" 'Mahnoor Shoukat',\n",
" 'hanfia sattar',\n",
" 'Hiba Rafiq',\n",
" 'Sadia Javed',\n",
" 'Hafsa Imtiaz',\n",
" 'Fahad Hashmi',\n",
" 'Iqra Ismail',\n",
" 'Azeem Khan',\n",
" 'muhammad usman',\n",
" 'Owais Saeed',\n",
" 'Dareer Khalid',\n",
" 'Tauqir Ahmed',\n",
" 'asad ahmad',\n",
" 'FJ',\n",
" 'Abdul Rehman',\n",
" 'Danish Siddiquie',\n",
" 'Huzaifa Aazmi',\n",
" 'Waqas Khan',\n",
" 'Memon Nadeemhabib',\n",
" 'Habib Sufyan',\n",
" 'waqar saleem',\n",
" 'Muhammad Umer Farooq',\n",
" 'Ali Mehdi',\n",
" 'Taj Ahmed',\n",
" 'Siyam Ansari',\n",
" 'Asfa Tabish',\n",
" 'Gul Zaman Shaikh',\n",
" 'Rohan Wasim',\n",
" 'Mahek Ali',\n",
" 'Irtiqa Khan',\n",
" 'Hammad Khan',\n",
" 'mansoor ahmed',\n",
" 'imran jamil',\n",
" 'Junaid Khan',\n",
" 'Saira Shaikh',\n",
" 'Shariq Bashir',\n",
" 'Asmat Mehmood',\n",
" 'Raheel Nadeem',\n",
" 'Saba Ali',\n",
" 'adeel Zaman',\n",
" 'Rosh Mirza',\n",
" 'Ashar Khaliq',\n",
" 'syed farman ali shah',\n",
" 'Haroon Saleem',\n",
" 'Shakeel Ahmed',\n",
" 'Syed Usman Ghani',\n",
" 'Abdul Samad Shaikh',\n",
" 'Muhammad Saad',\n",
" 'Vishah Fatima',\n",
" 'KAMRAN KHATRI',\n",
" 'Shafaat Ahmed Khan',\n",
" 'Uzma Farogh',\n",
" 'Akbar Khan',\n",
" 'bilal',\n",
" 'Bilal Khan',\n",
" 'Abdul Samad Shaikh',\n",
" 'Xyz',\n",
" 'Mahpara Badar',\n",
" 'Hasan Mehdi',\n",
" 'Imran Khan',\n",
" 'Jahanzeb Siddiqui',\n",
" 'Omema Akhtar',\n",
" 'Raniya Khan',\n",
" 'aqsa akmal',\n",
" 'Javeed Ahmed',\n",
" 'Ashar Khaliq',\n",
" 'faranaz keshwani',\n",
" 'Ahmed Naseem',\n",
" 'Saba Ali',\n",
" 'Talaal Yousoof',\n",
" 'Danish Siddiquie']"
]
},
"execution_count": 99,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"text = \"\"\"\n",
"Team NED Academy12:59 PM\n",
"Sir please start recording pleas\n",
"Iqra Ismail1:01 PM\n",
"no\n",
"Muhammad Abubakar1:01 PM\n",
"sir class end pe assignment ke baray mei thora guide krdejye ga\n",
"Iqra Ismail1:02 PM\n",
"yes\n",
"Altaf Hussain Bakhwani1:04 PM\n",
"yes\n",
"Muhammad Abubakar1:04 PM\n",
"clear hai sir\n",
"Talaal Yousoof1:04 PM\n",
"yes\n",
"Altaf Hussain Bakhwani1:07 PM\n",
"yes, action = method, character = attribute\n",
"Talaal Yousoof1:09 PM\n",
"what was attribute pls?\n",
"Uzma Farogh1:09 PM\n",
"sir some students are trying to join. please let them in\n",
"faranaz keshwani1:12 PM\n",
"how do you record attendance on online classes\n",
"Asfa Tabish1:23 PM\n",
"sir method and attribute repeat krdain pls\n",
"Ahmed Naseem1:25 PM\n",
"Yes, main ne bhi late join kiya hai. It would be helpful if you can revise a bit.\n",
"Ashar Khaliq1:39 PM\n",
"print(name.lower().count(\"m\"))\n",
"Rosh Mirza1:41 PM\n",
"name = \"I love my country \"\n",
"name = name.casefold()\n",
"print(\"y count:\",name.count('y'),\"m count :\",name.count('m'))\n",
"You2:17 PM\n",
"24mrw4t\n",
"Imran Haider2:26 PM\n",
"3130315904511\n",
"Muhammad Abubakar2:26 PM\n",
"42201-1270634-5\n",
"Aamir Pingal2:26 PM\n",
"423012945634\n",
"Talaal Yousoof2:26 PM\n",
"4220158211299\n",
"Ahmed Naseem2:26 PM\n",
"4200066399757\n",
"Muhammad Ovais2:26 PM\n",
"42101-4941-769-5\n",
"Atif Salam2:26 PM\n",
"42201-9446591-3\n",
"Altaf Hussain Bakhwani2:26 PM\n",
"4220105815527\n",
"Feroz Gul2:26 PM\n",
"44204-3335269-3\n",
"Jawwad Khan2:26 PM\n",
"42201-9848624-7\n",
"Mahnoor Shoukat2:26 PM\n",
"4250150754028\n",
"hanfia sattar2:26 PM\n",
"4220151056096\n",
"Hiba Rafiq2:26 PM\n",
"4230185868058\n",
"Sadia Javed2:26 PM\n",
"4220158772002\n",
"Hafsa Imtiaz2:26 PM\n",
"42201-8903447-4\n",
"Fahad Hashmi2:27 PM\n",
"4210180636569\n",
"Iqra Ismail2:27 PM\n",
"4220113160602\n",
"Azeem Khan2:27 PM\n",
"42101-7583355-9\n",
"muhammad usman2:27 PM\n",
"33203-1390549-7\n",
"Owais Saeed2:27 PM\n",
"4210187416487\n",
"Dareer Khalid2:27 PM\n",
"4220103150553\n",
"Tauqir Ahmed2:27 PM\n",
"4220157915361\n",
"asad ahmad2:27 PM\n",
"3130349769793\n",
"FJ2:27 PM\n",
"4210174737043\n",
"Abdul Rehman2:27 PM\n",
"4210113955917\n",
"Danish Siddiquie2:27 PM\n",
"4230174890321\n",
"Huzaifa Aazmi2:27 PM\n",
"42101-4717980-5\n",
"Waqas Khan2:27 PM\n",
"35202-2018037-1\n",
"Memon Nadeemhabib2:27 PM\n",
"4130627627273\n",
"Habib Sufyan2:27 PM\n",
"42101-9546976-1\n",
"waqar saleem2:27 PM\n",
"3740611871985\n",
"Muhammad Umer Farooq2:27 PM\n",
"4250141745875\n",
"Ali Mehdi2:27 PM\n",
"42101-0883203-9\n",
"Taj Ahmed2:27 PM\n",
"42101-5086613-3\n",
"Siyam Ansari2:27 PM\n",
"45504-6691184-5\n",
"Asfa Tabish2:27 PM\n",
"42201-3317436-4\n",
"Gul Zaman Shaikh2:27 PM\n",
"42301-4208474-9\n",
"Gul Zaman\n",
"Rohan Wasim2:27 PM\n",
"4210156852483\n",
"Mahek Ali2:27 PM\n",
"4220119350184\n",
"Irtiqa Khan2:27 PM\n",
"42501-1882684-3\n",
"Hammad Khan2:27 PM\n",
"42201-2206678-9\n",
"mansoor ahmed2:27 PM\n",
"41303-1217008-9\n",
"imran jamil2:27 PM\n",
"42201-2367694-3\n",
"Junaid Khan2:27 PM\n",
"4250118835393\n",
"Saira Shaikh2:27 PM\n",
"4220182635186\n",
"Shariq Bashir2:27 PM\n",
"42101-1743803-7\n",
"Asmat Mehmood2:27 PM\n",
"423018695739\n",
"Raheel Nadeem2:27 PM\n",
"4220114028509\n",
"Saba Ali2:27 PM\n",
"42301-3905834-2\n",
"adeel Zaman2:27 PM\n",
"4240116015521 adeel zaman\n",
"Rosh Mirza2:27 PM\n",
"4420651603848\n",
"Ashar Khaliq2:27 PM\n",
"4200004676915\n",
"syed farman ali shah2:27 PM\n",
"1510203461495\n",
"Haroon Saleem2:27 PM\n",
"4240156992579\n",
"Shakeel Ahmed2:27 PM\n",
"4240119589433\n",
"Syed Usman Ghani2:27 PM\n",
"4210109155877\n",
"Abdul Samad Shaikh2:27 PM\n",
"4210255467543\n",
"Muhammad Saad2:27 PM\n",
"42201-4144981-5\n",
"Vishah Fatima2:27 PM\n",
"4210170628928\n",
"KAMRAN KHATRI2:27 PM\n",
"4230198076489\n",
"Shafaat Ahmed Khan2:27 PM\n",
"42201-3225780-3\n",
"Uzma Farogh2:27 PM\n",
"4210190028920\n",
"Akbar Khan2:27 PM\n",
"4220106865377\n",
"bilal2:28 PM\n",
"4210164911883\n",
"Bilal Khan2:28 PM\n",
"42501-3607843-1\n",
"Abdul Samad Shaikh2:28 PM\n",
"4210184328497\n",
"Xyz2:28 PM\n",
"4210118094301\n",
"Mahpara Badar2:28 PM\n",
"4210111752498\n",
"Hasan Mehdi2:28 PM\n",
"4210144676677\n",
"Imran Khan2:28 PM\n",
"4130498094753\n",
"Jahanzeb Siddiqui2:29 PM\n",
"4210169925379\n",
"Omema Akhtar2:29 PM\n",
"4210151840638 omema Akhtar\n",
"Raniya Khan2:29 PM\n",
"42201-9978093-2\n",
"aqsa akmal2:29 PM\n",
"4220145184200\n",
"Javeed Ahmed2:30 PM\n",
"4220141864935\n",
"Ashar Khaliq2:30 PM\n",
"%d\n",
"faranaz keshwani2:31 PM\n",
"42201-7992036-2\n",
"42201-7992036-2 Faranaz Surani\n",
"Ahmed Naseem2:32 PM\n",
"13 digit\n",
"Saba Ali2:32 PM\n",
"13\n",
"Talaal Yousoof2:32 PM\n",
"13\n",
"Danish Siddiquie2:32 PM\n",
"13\n",
"\"\"\"\n",
"\n",
"import re\n",
"\n",
"names = re.findall(\"(.*)\\d+:\\d+ PM\", text)\n",
"names"
]
},
{
"cell_type": "code",
"execution_count": 114,
"id": "256f246d-ea82-4027-9f9e-5a1b4cf9b14c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Time</th>\n",
" <th>Name</th>\n",
" <th>Roll No</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>12:05:40</td>\n",
" <td>Ali Asar</td>\n",
" <td>PIAIC-187258</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>12:05:41</td>\n",
" <td>Hasnain Munir</td>\n",
" <td>PIAIC-187272</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>12:05:44</td>\n",
" <td>Shaheer Baig</td>\n",
" <td>PIAIC-169519</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>12:05:45</td>\n",
" <td>Humera Naz</td>\n",
" <td>PIAIC-173431</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>12:05:47</td>\n",
" <td>Sadia Anwar</td>\n",
" <td>PIAIC-180028</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>12:05:47</td>\n",
" <td>Muhammad Mehroz</td>\n",
" <td>PIAIC-131496</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>12:05:47</td>\n",
" <td>Home</td>\n",
" <td>PIAIC-172998</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>12:05:47</td>\n",
" <td>Muhammad Sadullah = PIAIC-178950</td>\n",
" <td>PIAIC-178950</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>12:05:48</td>\n",
" <td>Muhammad Uzair-177637</td>\n",
" <td>PIAIC-177637</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>12:05:48</td>\n",
" <td>Taqwa Khaliq</td>\n",
" <td>PIAIC-173701</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>12:05:49</td>\n",
" <td>Faisal Bashir-177802</td>\n",
" <td>PIAIC-177802</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>12:05:50</td>\n",
" <td>Talha Munir Rana</td>\n",
" <td>PIAIC-173761</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>12:05:52</td>\n",
" <td>Abdul Qadar</td>\n",
" <td>PIAIC-172941</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>12:05:57</td>\n",
" <td>Dr. Bhagwan Das</td>\n",
" <td>PIAIC-96879</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>12:05:57</td>\n",
" <td>Uzair Ullah (PIAIC169405)</td>\n",
" <td>PIAIC-169405</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>12:06:00</td>\n",
" <td>Arshad</td>\n",
" <td>PIAIC168092</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>12:06:01</td>\n",
" <td>PIAIC188523 Subhan Ahmed</td>\n",
" <td>PIAIC188523</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>12:06:10</td>\n",
" <td>Ali Asar</td>\n",
" <td>PIAIC-188720</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>12:06:28</td>\n",
" <td>Gulshan Ali</td>\n",
" <td>PIAIC-176719</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>12:06:29</td>\n",
" <td>M Ali Asif Khan - PIAIC-57947</td>\n",
" <td>PIAIC-57947</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>12:06:33</td>\n",
" <td>Usman Noor PIAIC-188401</td>\n",
" <td>PIAIC-188401</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>12:06:49</td>\n",
" <td>Sohaib Baseer Ahmad</td>\n",
" <td>PIAIC67260</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>12:40:20</td>\n",
" <td>Ali Asar</td>\n",
" <td>PIAIC-187258</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Time Name Roll No\n",
"0 12:05:40 Ali Asar PIAIC-187258\n",
"1 12:05:41 Hasnain Munir PIAIC-187272\n",
"2 12:05:44 Shaheer Baig PIAIC-169519\n",
"3 12:05:45 Humera Naz PIAIC-173431\n",
"4 12:05:47 Sadia Anwar PIAIC-180028\n",
"5 12:05:47 Muhammad Mehroz PIAIC-131496\n",
"6 12:05:47 Home PIAIC-172998\n",
"7 12:05:47 Muhammad Sadullah = PIAIC-178950 PIAIC-178950\n",
"8 12:05:48 Muhammad Uzair-177637 PIAIC-177637\n",
"9 12:05:48 Taqwa Khaliq PIAIC-173701\n",
"10 12:05:49 Faisal Bashir-177802 PIAIC-177802\n",
"11 12:05:50 Talha Munir Rana PIAIC-173761\n",
"12 12:05:52 Abdul Qadar PIAIC-172941\n",
"13 12:05:57 Dr. Bhagwan Das PIAIC-96879\n",
"14 12:05:57 Uzair Ullah (PIAIC169405) PIAIC-169405\n",
"15 12:06:00 Arshad PIAIC168092\n",
"16 12:06:01 PIAIC188523 Subhan Ahmed PIAIC188523\n",
"17 12:06:10 Ali Asar PIAIC-188720\n",
"18 12:06:28 Gulshan Ali PIAIC-176719\n",
"19 12:06:29 M Ali Asif Khan - PIAIC-57947 PIAIC-57947\n",
"20 12:06:33 Usman Noor PIAIC-188401 PIAIC-188401\n",
"21 12:06:49 Sohaib Baseer Ahmad PIAIC67260\n",
"22 12:40:20 Ali Asar PIAIC-187258"
]
},
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = \"\"\"\n",
"\n",
"12:05:40 From Ali Asar To Everyone : PIAIC-187258\n",
"12:05:41 From Hasnain Munir To Everyone : PIAIC-187272\n",
"12:05:44 From Shaheer Baig To Everyone : PIAIC-169519\n",
"12:05:45 From Humera Naz To Everyone : PIAIC-173431\n",
"12:05:47 From Sadia Anwar To Everyone : PIAIC-180028\n",
"12:05:47 From Muhammad Mehroz To Everyone : PIAIC-131496\n",
"12:05:47 From Home To Everyone : PIAIC-172998\n",
"12:05:47 From Muhammad Sadullah = PIAIC-178950 To Everyone : PIAIC-178950\n",
"12:05:48 From Muhammad Uzair-177637 To Everyone : PIAIC-177637\n",
"12:05:48 From Taqwa Khaliq To Everyone : PIAIC-173701 TAQWA KHALIQ\n",
"12:05:48 From asghar ibraheem CNC-012105 To Everyone : CNC-012105\n",
"12:05:49 From Faisal Bashir-177802 To Everyone : PIAIC-177802\n",
"12:05:50 From Talha Munir Rana To Everyone : PIAIC-173761\n",
"12:05:52 From Abdul Qadar To Everyone : PIAIC-172941\n",
"12:05:57 From Dr. Bhagwan Das To Everyone : PIAIC-96879\n",
"12:05:57 From Uzair Ullah (PIAIC169405) To Everyone : PIAIC-169405\n",
"12:06:00 From Arshad To Everyone : PIAIC168092\n",
"12:06:01 From PIAIC188523 Subhan Ahmed To Everyone : PIAIC188523\n",
"12:06:04 From Taqwa Khaliq To Everyone : PIAIC 173701\n",
"12:06:10 From Ali Asar To Everyone : PIAIC-188720\n",
"12:06:23 From Mohammad Javed To Everyone : WhatsApp number?\n",
"12:06:28 From Gulshan Ali To Everyone : PIAIC-176719\n",
"12:06:29 From M Ali Asif Khan - PIAIC-57947 To Everyone : PIAIC-57947\n",
"12:06:33 From Usman Noor PIAIC-188401 To Everyone : PIAIC-188401\n",
"12:06:46 From Zia (piaic121514) To Everyone : thanks\n",
"12:06:49 From Sohaib Baseer Ahmad To Everyone : PIAIC67260\n",
"12:40:20 From Ali Asar To Everyone : PIAIC-187258\n",
"\n",
"\"\"\"\n",
"\n",
"import re\n",
"\n",
"d = re.findall(\"(\\d{2}:\\d{2}:\\d{2}) From (.*?) To Everyone : (PIAIC-?\\d{5,6})\", data)\n",
"d = pd.DataFrame(d,columns=[\"Time\",\"Name\",\"Roll No\"])\n",
"d"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7df92100-69bb-4e0e-8c32-85f261cfdfb4",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|