{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["Function"],"metadata":{"id":"FejNgtpuyzkc"}},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"wAaYEVvGyxen","executionInfo":{"status":"ok","timestamp":1733549772692,"user_tz":-360,"elapsed":662,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"8add8ff1-3b39-48c5-e08d-1b7da3656b81"},"outputs":[{"output_type":"stream","name":"stdout","text":["Even\n","Odd\n"]}],"source":["# Write a Python function even_odd(n) that takes an integer n as input and prints \"Even\" if the number is even and \"Odd\" if the number is odd.\n","def even_odd(n):\n"," if n % 2 == 0:\n"," print(\"Even\")\n"," else:\n"," print(\"Odd\")\n","\n","even_odd(24)\n","even_odd(71)"]},{"cell_type":"code","source":["\"\"\"\n","Write a function divideOnly(n) that prints numbers from 1 to n with special labels:\n","\"divide by 3 or 5\" for numbers divisible by both 3 and 5.\n","\"divide by 3\" for numbers divisible by 3 only.\n","\"divide by 5\" for numbers divisible by 5 only.\n","Otherwise, print the number.\n","What is the output of divideOnly(10)?\n","\"\"\"\n","def divideOnly(n):\n"," for i in range(1, n + 1):\n"," if i % 3 == 0 and i % 5 == 0:\n"," print(\"divide by 3 or 5\")\n"," elif i % 3 == 0:\n"," print(\"divide by 3\")\n"," elif i % 5 == 0:\n"," print(\"divide by 5\")\n"," else:\n"," print(i)\n","\n","divideOnly(10)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"k0z2gbpmzJG4","executionInfo":{"status":"ok","timestamp":1733039829652,"user_tz":-360,"elapsed":4,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"6b5b43fc-8a74-4be6-f722-1d88e571099d"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["1\n","2\n","divide by 3\n","4\n","divide by 5\n","divide by 3\n","7\n","8\n","divide by 3\n","divide by 5\n"]}]},{"cell_type":"code","source":["# Write a recursive function factorial(n) that calculates the factorial of a number n.\n","def factorial(n):\n"," if n == 1:\n"," return 1\n"," else:\n"," result = n * factorial(n - 1)\n"," return result\n","\n","print(factorial(5))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"jAGonT6X0l7I","executionInfo":{"status":"ok","timestamp":1733039829652,"user_tz":-360,"elapsed":3,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"1e51b571-12a4-448a-9264-d30514d2fcad"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["120\n"]}]},{"cell_type":"code","source":["# Write a Python function number_pattern() that prints a right-angled triangle pattern of asterisks (*) based on the number of rows. Each row contains one more asterisk than the previous row.\n","def number_pattern(rows):\n"," for i in range(1, rows + 1):\n"," for j in range(1, i + 1):\n"," print('*', end=\" \")\n"," print()\n","\n","number_pattern(5)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"oYhli8lf081J","executionInfo":{"status":"ok","timestamp":1733039829652,"user_tz":-360,"elapsed":1,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"86126279-5326-4ff6-a481-6a4061d074f5"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["* \n","* * \n","* * * \n","* * * * \n","* * * * * \n"]}]},{"cell_type":"code","source":["# Write a Python function number_pattern(rows) that prints an inverted right-angled triangle pattern of asterisks (*). The number of asterisks starts with rows in the first row and decreases by one in each subsequent row.\n","def number_pattern(rows):\n"," for i in range(rows, 0, -1):\n"," for j in range(1, i + 1):\n"," print('*', end=\" \")\n"," print()\n","\n","number_pattern(5)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"vwceCdLq2Qh6","executionInfo":{"status":"ok","timestamp":1733039830143,"user_tz":-360,"elapsed":17,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"feba2385-d18c-43e6-921b-8ae483069055"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["* * * * * \n","* * * * \n","* * * \n","* * \n","* \n"]}]},{"cell_type":"code","source":["\"\"\"\n","Write a Python function grade_calculator() that calculates grades based on the given score:\n","\"A+\" for scores 80 and above.\n","\"A\" for scores 70–79.\n","\"A-\" for scores 60–69.\n","\"B\" for scores 50–59.\n","\"C\" for scores 40–49.\n","\"D\" for scores 33–39.\n","\"F\" for scores below 33.\n","Return \"Invalid score\" for inputs below 0 or above 100.\n","\"\"\"\n","def grade_calculator(score):\n"," if score < 0 or score > 100:\n"," return \"Invalid score\"\n"," elif score >= 80:\n"," return \"A+\"\n"," elif score >= 70:\n"," return \"A\"\n"," elif score >= 60:\n"," return \"A-\"\n"," elif score >= 50:\n"," return \"B\"\n"," elif score >= 40:\n"," return \"C\"\n"," elif score >= 33:\n"," return \"D\"\n"," else:\n"," return \"F\"\n","\n","print(grade_calculator(85))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"67sYOVkD2_OP","executionInfo":{"status":"ok","timestamp":1733484029667,"user_tz":-360,"elapsed":1116,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"1f95e3df-18b6-4496-8c16-f1184a1c1f4b"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["A+\n"]}]},{"cell_type":"code","source":["# Write a Python function is_prime(n) that checks if a number n is a prime number.\n","def is_prime(n):\n"," if n <= 1:\n"," return False\n"," for i in range(2, n):\n"," if n % i == 0:\n"," return False\n"," return True\n","\n","number = 2\n","if is_prime(number):\n"," print(f\"{number} is a prime number.\")\n","else:\n"," print(f\"{number} is not a prime number.\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"vOSGwRYs51Xp","executionInfo":{"status":"ok","timestamp":1733039830143,"user_tz":-360,"elapsed":14,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"213e8326-3abe-426b-f30b-b8b801707995"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["2 is a prime number.\n"]}]},{"cell_type":"code","source":["# Write a Python function get_key_by_value(d, value) that takes a dictionary d and a value value, and returns the key associated with that value. If the value is not found, return None.\n","def get_key_by_value(d, value):\n"," for key, val in d.items():\n"," if val == value:\n"," return key\n"," return None\n","\n","my_dict = {\"a\": 1, \"b\": 2, \"c\": 3}\n","print(get_key_by_value(my_dict, 2))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Ggb8JeYG7urE","executionInfo":{"status":"ok","timestamp":1733484510441,"user_tz":-360,"elapsed":469,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"18790fd2-0af0-46cf-9d74-eb318118d18e"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["b\n"]}]},{"cell_type":"code","source":["# Write a Python function update_dict_value(d, key, value) that updates the value of a given key in the dictionary d with the new value. Return the updated dictionary.\n","def update_dict_value(d, key, value):\n"," d[key] = value\n"," return d\n","\n","my_dict = {\"a\": 1, \"b\": 2}\n","print(update_dict_value(my_dict, \"b\", 5))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"X-7OOS108Qyv","executionInfo":{"status":"ok","timestamp":1733039830143,"user_tz":-360,"elapsed":13,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"72c2fa37-70e2-4cf7-d3dc-6d65b3e341f9"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["{'a': 1, 'b': 5}\n"]}]},{"cell_type":"code","source":["# Write a Python function remove_key(d, key) that removes a specified key from the dictionary d. If the key exists, it should be deleted. Return the updated dictionary.\n","def remove_key(d, key):\n"," if key in d:\n"," del d[key]\n"," return d\n","\n","my_dict = {\"a\": 1, \"b\": 2, \"c\": 3}\n","print(remove_key(my_dict, \"b\"))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"qKvVm5Ft8ZuY","executionInfo":{"status":"ok","timestamp":1733039830143,"user_tz":-360,"elapsed":12,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"2f4844b7-00e4-4546-f199-48ccb48017ee"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["{'a': 1, 'c': 3}\n"]}]},{"cell_type":"code","source":["# Write a Python function key_exists(d, key) that checks if a given key exists in the dictionary d.\n","def key_exists(d, key):\n"," return key in d\n","\n","my_dict = {\"a\": 1, \"b\": 2, \"c\": 3}\n","print(key_exists(my_dict, \"b\"))\n","print(key_exists(my_dict, \"d\"))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"zr-jJTBS8iqy","executionInfo":{"status":"ok","timestamp":1733039830143,"user_tz":-360,"elapsed":11,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"f312be5b-6a1b-4647-8357-39a089eb42ff"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["True\n","False\n"]}]},{"cell_type":"code","source":["# Write a Python function traverse_nested_dict(d) that recursively traverses through a nested dictionary d. The function should print each key-value pair, and if the value is another dictionary, it should recurse into that dictionary.\n","def traverse_nested_dict(d):\n"," for key, value in d.items():\n"," if isinstance(value, dict):\n"," print(f\"{key}:\")\n"," traverse_nested_dict(value)\n"," else:\n"," print(f\"{key}: {value}\")\n","\n","nested_dict = {\"a\": 1, \"b\": {\"x\": 10, \"y\": 20}, \"c\": 3}\n","traverse_nested_dict(nested_dict)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"1iVtZSHV8or6","executionInfo":{"status":"ok","timestamp":1733485190157,"user_tz":-360,"elapsed":381,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"1e410662-e215-41dc-ae1a-81c4f26c13eb"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["a: 1\n","b:\n","x: 10\n","y: 20\n","c: 3\n"]}]},{"cell_type":"code","source":["bubt_students = {\n"," 'squadName': 'BUBT Students',\n"," 'homeTown': 'Dhaka',\n"," 'formed': 2003,\n"," 'secretBase': 'BUBT Campus',\n"," 'active': True,\n"," 'members': [\n"," {\n"," 'name': 'Arif Hasan',\n"," 'age': 22,\n"," 'secretIdentity': 'Arif',\n"," 'powers': ['ProblemSolving', 'Coding', 'WebDevelopment', 'Speed']\n"," },\n"," {\n"," 'name': 'Sakina Rahman',\n"," 'age': 21,\n"," 'secretIdentity': 'Sakina',\n"," 'powers': ['Designing', 'Creativity', 'Graphics', 'UXKnowledge']\n"," },\n"," {\n"," 'name': 'Tariq Ahmed',\n"," 'age': 23,\n"," 'secretIdentity': 'Tariq',\n"," 'powers': ['Mathematics', 'Optimization', 'DataAnalysis', 'ProblemSolving']\n"," },\n"," {\n"," 'name': 'Nadia Rahman',\n"," 'age': 22,\n"," 'secretIdentity': 'Nadia',\n"," 'powers': ['Leadership', 'Planning', 'ProblemSolving', 'WebDevelopment']\n"," }\n"," ]\n","}\n"],"metadata":{"id":"ZxibEapN9Wak"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["def add_student(name, age, secret_identity, powers):\n"," new_student = {\n"," \"name\": name,\n"," \"age\": age,\n"," \"secretIdentity\": secret_identity,\n"," \"powers\": powers\n"," }\n"," bubt_students['members'].append(new_student)\n"," print(f\"Student {name} added successfully!\")\n","\n","add_student(\"Razaul Islam\", 24, \"Razaul\", [\"Great at AI\", \"Expert in Machine Learning\", \"Can analyze large datasets\"])"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"KeNELY09KFqB","executionInfo":{"status":"ok","timestamp":1733485206967,"user_tz":-360,"elapsed":395,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"7009be91-7a58-46f2-b886-072e05fd9011"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Student Razaul Islam added successfully!\n"]}]},{"cell_type":"code","source":["def get_student(name):\n"," for student in bubt_students['members']:\n"," if student['name'] == name:\n"," return student\n"," return f\"Student {name} not found.\"\n","\n","print(get_student(\"Arif Hasan\"))"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"uj0wTHeBM3o6","executionInfo":{"status":"ok","timestamp":1733485210016,"user_tz":-360,"elapsed":387,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"49b0d6a1-ee82-4a66-afbc-ab381aaaa039"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["{'name': 'Arif Hasan', 'age': 22, 'secretIdentity': 'Arif', 'powers': ['ProblemSolving', 'Coding', 'WebDevelopment', 'Speed']}\n"]}]},{"cell_type":"code","source":["def update_student(name, new_age=None, new_powers=None):\n"," for student in bubt_students['members']:\n"," if student['name'] == name:\n"," if new_age:\n"," student['age'] = new_age\n"," if new_powers:\n"," student['powers'] = new_powers\n"," print(f\"Student {name} updated successfully!\")\n"," return\n"," print(f\"Student {name} not found.\")\n","\n","update_student(\"Sakina Rahman\", new_age=22, new_powers=[\"Creative with new designs\", \"Knows how to design mobile apps\"])"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"WzhNnXvENLus","executionInfo":{"status":"ok","timestamp":1733485219957,"user_tz":-360,"elapsed":374,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"ca8eb4e1-2434-4e17-820f-c6d0a838f8df"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Student Sakina Rahman updated successfully!\n"]}]},{"cell_type":"code","source":["def delete_student(name):\n"," for student in bubt_students['members']:\n"," if student['name'] == name:\n"," bubt_students['members'].remove(student)\n"," print(f\"Student {name} deleted successfully!\")\n"," return\n"," print(f\"Student {name} not found.\")\n","\n","\n","delete_student(\"Tariq Ahmed\")"],"metadata":{"id":"eDx3vLt0CMkE","executionInfo":{"status":"ok","timestamp":1733485222854,"user_tz":-360,"elapsed":409,"user":{"displayName":"44-271-Munsi Walid Al Hassan Nizhu","userId":"16216461530557409787"}},"outputId":"20b1791f-2392-40d6-92d7-ef5bf4e392e4","colab":{"base_uri":"https://localhost:8080/"}},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Student Tariq Ahmed deleted successfully!\n"]}]},{"cell_type":"code","source":["faculty = {\n"," 'Sudipto Chaki': {\n"," 'name': 'Sudipto Chaki',\n"," 'position': {\n"," 'title': 'Assistant Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'SCK',\n"," 'Email': 'sudiptochakibd@gmail.com',\n"," },\n"," 'details': {\n"," 'class rating': '5',\n"," 'Specialist': 'AI',\n"," 'skills': ['Python', 'ML', 'GenAI']\n"," }\n"," },\n"," 'Anika Rahman': {\n"," 'name': 'Anika Rahman',\n"," 'position': {\n"," 'title': 'Lecturer',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'ARK',\n"," 'Email': 'anika.rahman@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '4.7',\n"," 'Specialist': 'Cybersecurity',\n"," 'skills': ['Ethical Hacking', 'Network Security', 'Python']\n"," }\n"," },\n"," 'Tanvir Ahmed': {\n"," 'name': 'Tanvir Ahmed',\n"," 'position': {\n"," 'title': 'Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'TAH',\n"," 'Email': 'tanvir.ahmed@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '5',\n"," 'Specialist': 'Software Engineering',\n"," 'skills': ['Java', 'Agile Methodologies', 'System Design']\n"," }\n"," },\n"," 'Mahi Hasan': {\n"," 'name': 'Mahi Hasan',\n"," 'position': {\n"," 'title': 'Assistant Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'MHN',\n"," 'Email': 'mahi.hasan@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '4.8',\n"," 'Specialist': 'Robotics',\n"," 'skills': ['Robotics', 'C++', 'ROS']\n"," }\n"," },\n"," 'Sadia Islam': {\n"," 'name': 'Sadia Islam',\n"," 'position': {\n"," 'title': 'Lecturer',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'SIS',\n"," 'Email': 'sadia.islam@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '4.6',\n"," 'Specialist': 'NLP',\n"," 'skills': ['NLP', 'Python', 'Hugging Face']\n"," }\n"," },\n"," 'Rafiq Rahman': {\n"," 'name': 'Rafiq Rahman',\n"," 'position': {\n"," 'title': 'Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'RRN',\n"," 'Email': 'rafiq.rahman@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '5',\n"," 'Specialist': 'Data Science',\n"," 'skills': ['R', 'Python', 'Pandas']\n"," }\n"," },\n"," 'Tania Akter': {\n"," 'name': 'Tania Akter',\n"," 'position': {\n"," 'title': 'Lecturer',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'TAR',\n"," 'Email': 'tania.akter@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '4.5',\n"," 'Specialist': 'Computer Vision',\n"," 'skills': ['OpenCV', 'Deep Learning', 'TensorFlow']\n"," }\n"," },\n"," 'Nafis Hossain': {\n"," 'name': 'Nafis Hossain',\n"," 'position': {\n"," 'title': 'Assistant Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'NHN',\n"," 'Email': 'nafis.hossain@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '4.9',\n"," 'Specialist': 'Cloud Computing',\n"," 'skills': ['AWS', 'Azure', 'Kubernetes']\n"," }\n"," },\n"," 'Farzana Alam': {\n"," 'name': 'Farzana Alam',\n"," 'position': {\n"," 'title': 'Lecturer',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'FAN',\n"," 'Email': 'farzana.alam@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '4.6',\n"," 'Specialist': 'Human-Computer Interaction',\n"," 'skills': ['UI/UX Design', 'Prototyping', 'Figma']\n"," }\n"," },\n"," 'Kamal Hossain': {\n"," 'name': 'Kamal Hossain',\n"," 'position': {\n"," 'title': 'Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': 'KHN',\n"," 'Email': 'kamal.hossain@example.com',\n"," },\n"," 'details': {\n"," 'class rating': '5',\n"," 'Specialist': 'Algorithms',\n"," 'skills': ['Algorithm Design', 'Competitive Programming', 'C++']\n"," }\n"," }\n","}"],"metadata":{"id":"IINkymTL4SHs"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["1. Write a Python code snippet to find and print the email and specialist area of \"Mahi Hasan\" from the Faculty dictionary.\n","\n","2. Write a Python function to count and return the number of professors in the Faculty dictionary.\n","\n","3. Write a Python snippet to determine which faculty member(s) has the highest class rating in the Faculty dictionary.\n","\n","4. Write a Python function that takes a skill (e.g., 'Python') as input and returns a list of faculty names who have that skill in their skillset.\n","\n","5. Write a Python code snippet to add the following new faculty member to the Faculty dictionary."],"metadata":{"id":"ABkeYwxM5rHR"}},{"cell_type":"code","source":["# 1. Write a Python code snippet to find and print the email and specialist area of \"Mahi Hasan\" from the Faculty dictionary.\n","for i in faculty:\n"," if i == 'Mahi Hasan':\n"," print('Email: ',faculty[i]['position']['Email'])\n"," print('Specialist: ',faculty[i]['details']['Specialist'])"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"k7-Tn2Af5vEt","executionInfo":{"status":"ok","timestamp":1733135809474,"user_tz":-360,"elapsed":430,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"442a0cfb-7d1a-4731-ae27-08894e749674"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Email: mahi.hasan@example.com\n","Specialist: Robotics\n"]}]},{"cell_type":"code","source":["# 2. Write a Python function to count and return the number of professors in the Faculty dictionary.\n","# def count_faculty(faculty):\n","# count = 0\n","# for i,j in faculty.items():\n","# for k,l in j['position'].items():\n","# if l == 'Professor':\n","# count += 1\n","# print(count)\n","# count_faculty(faculty)\n","\n","count = 0\n","for i in faculty:\n"," if faculty[i]['position']['title'] == 'Professor':\n"," count += 1\n","print(count)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"LCahDD2S6oPj","executionInfo":{"status":"ok","timestamp":1733136624207,"user_tz":-360,"elapsed":388,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"b2639755-19d4-4307-d4cb-de973b89e4b5"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["3\n"]}]},{"cell_type":"code","source":["# 3. Write a Python snippet to determine which faculty member(s) has the highest class rating in the Faculty dictionary.\n","highest_rating = 0\n","highest_faculty = ''\n","for i in faculty:\n"," if float(faculty[i]['details']['class rating']) > highest_rating:\n"," highest_rating = float(faculty[i]['details']['class rating'])\n"," highest_faculty = i\n","print(highest_faculty,':',highest_rating)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0ovUHodH_4uP","executionInfo":{"status":"ok","timestamp":1733136881083,"user_tz":-360,"elapsed":400,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"9fd0bf59-a1ae-45a5-f256-7b3f0a6fc358"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Sudipto Chaki : 5.0\n"]}]},{"cell_type":"code","source":["# 4. Write a Python function that takes a skill (e.g., 'Python') as input and returns a list of faculty names who have that skill in their skillset.\n","skl = input('Enter a skill: ')\n","for i in faculty:\n"," if skl in faculty[i]['details']['skills']:\n"," print(i)"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"LC10gAYYAnRj","executionInfo":{"status":"ok","timestamp":1733137087388,"user_tz":-360,"elapsed":3612,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"f959c6e1-0f2d-49c9-b8c9-43e175294b52"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["Enter a skill: Python\n","Sudipto Chaki\n","Anika Rahman\n","Sadia Islam\n","Rafiq Rahman\n"]}]},{"cell_type":"code","source":["# 5. Write a Python code snippet to add the following new faculty member to the Faculty dictionary.\n","faculty.update({'New Faculty': {\n"," 'name': 'New Faculty',\n"," 'position': {\n"," 'title': 'Assistant Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': ''},\n"," 'details': {'class rating': '','Specialist': 'AI','skills': ['Python', 'ML', 'GenAI']}\n"," }})"],"metadata":{"id":"gzy3-gPLBeVw"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["faculty['New Faculty']"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"-qkmnKV99P4K","executionInfo":{"status":"ok","timestamp":1733138068031,"user_tz":-360,"elapsed":487,"user":{"displayName":"Walid Al Hassan","userId":"16251668036492215176"}},"outputId":"5ecb795a-380d-4025-a4dc-fe8b1cab13c4"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["{'name': 'New Faculty',\n"," 'position': {'title': 'Assistant Professor',\n"," 'department': 'Department of Computer Science & Engineering',\n"," 'faculty code': ''},\n"," 'details': {'class rating': '',\n"," 'Specialist': 'AI',\n"," 'skills': ['Python', 'ML', 'GenAI']}}"]},"metadata":{},"execution_count":81}]}]}