{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "2224f9a4-403e-4ec9-81c2-4078bd9403cc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\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", "\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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CNIC
04230139058342
14210255467543
24220157915361
34550466911845
44210111752498
......
694240116015521
704420651603848
714220113160602
724220198486247
734220105815527
\n", "

74 rows × 1 columns

\n", "
" ], "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TimeNameRoll No
012:05:40Ali AsarPIAIC-187258
112:05:41Hasnain MunirPIAIC-187272
212:05:44Shaheer BaigPIAIC-169519
312:05:45Humera NazPIAIC-173431
412:05:47Sadia AnwarPIAIC-180028
512:05:47Muhammad MehrozPIAIC-131496
612:05:47HomePIAIC-172998
712:05:47Muhammad Sadullah = PIAIC-178950PIAIC-178950
812:05:48Muhammad Uzair-177637PIAIC-177637
912:05:48Taqwa KhaliqPIAIC-173701
1012:05:49Faisal Bashir-177802PIAIC-177802
1112:05:50Talha Munir RanaPIAIC-173761
1212:05:52Abdul QadarPIAIC-172941
1312:05:57Dr. Bhagwan DasPIAIC-96879
1412:05:57Uzair Ullah (PIAIC169405)PIAIC-169405
1512:06:00ArshadPIAIC168092
1612:06:01PIAIC188523 Subhan AhmedPIAIC188523
1712:06:10Ali AsarPIAIC-188720
1812:06:28Gulshan AliPIAIC-176719
1912:06:29M Ali Asif Khan - PIAIC-57947PIAIC-57947
2012:06:33Usman Noor PIAIC-188401PIAIC-188401
2112:06:49Sohaib Baseer AhmadPIAIC67260
2212:40:20Ali AsarPIAIC-187258
\n", "
" ], "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 }