Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions Kodify_test_by_Ifza.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"**Recruitment TEst Kodify by Ifza shad**\n",
"\n",
"**Q3 answer.**"
],
"metadata": {
"id": "HOof4GoLock0"
}
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "QlAjJW2HoW2R",
"outputId": "59fc8083-aa79-41dd-a80e-9c3dadfa84c8"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Median = 3\n"
]
}
],
"source": [
"# Python3 program for the above approach\n",
"def Solution(arr):\n",
" \n",
" n = len(arr)\n",
" \n",
" # If length of array is even\n",
" if n % 2 == 0:\n",
" z = n // 2\n",
" e = arr[z]\n",
" q = arr[z - 1]\n",
" ans = (e + q) / 2\n",
" return ans\n",
" \n",
" # If length of array is odd\n",
" else:\n",
" z = n // 2\n",
" ans = arr[z]\n",
" return ans\n",
" \n",
"# Driver code\n",
"if __name__ == \"__main__\":\n",
" \n",
" arr1 = [ -5, 3, 6, 12, 15 ]\n",
" arr2 = [ -12, -10, -6, -3, 4, 10 ]\n",
" \n",
" # Concatenating the two arrays\n",
" arr3 = arr1 + arr2\n",
" \n",
" # Sorting the resultant array\n",
" arr3.sort()\n",
" \n",
" print(\"Median = \", Solution(arr3))"
]
}
]
}