Below is the implementation:<\/strong><\/p>\n# Import the numpy library as np using the import function.\r\nimport numpy as np\r\n# Pass the lower limit, upper limit, and step size with some random numbers to the\r\n# range() function and convert it into a list using the list() function.\r\n# It is considered as the dataset.\r\n# Store it in a variable.\r\ngvn_dataset = list(range(70, 200, 10))\r\n# Pass the above dataset,\u00a0 0.25\u00a0 deviation as the arguments to the quantile()\r\n# function and store it in a variable.\r\nquartle_1 = np.quantile(gvn_dataset, 0.25)\r\n# Pass the above dataset,\u00a0 0.50\u00a0 deviation as the arguments to the quantile()\r\n# function and store it in another variable.\r\nquartle_2 = np.quantile(gvn_dataset, 0.50)\r\n# Pass the above dataset,\u00a0 0.75 deviation as the arguments to the quantile()\r\n# function and store it in another variable.\r\nquartle_3 = np.quantile(gvn_dataset, 0.75)\r\n# Print the above three variables i.e, quartile1, quartile1, and quartile1.\r\nprint(\"The 1st Quartile = \", quartle_1)\r\nprint(\"The 2nd Quartile = \", quartle_2)\r\nprint(\"The 3rd Quartile = \", quartle_3)\r\n# Create a function say quartile_deviatn() which accepts two numbers as the\r\n# arguments and returns half of the difference of two numbers.\r\n\r\n\r\ndef quartile_deviatn(x, y):\r\n # Inside the function, return the value half of the difference of two numbers\r\n # ((x - y)\/2).\r\n return (x - y)\/2\r\n\r\n\r\n# Pass the quartile3, quartile1 as arguments to the quartile_deviatn() function\r\n# and store it in a variable.\r\nrslt = quartile_deviatn(quartle_3, quartle_1)\r\n# Print the above result.\r\nprint(\"The result is = \", rslt)\r\n<\/pre>\nOutput:<\/strong><\/p>\nThe 1st Quartile = 100.0\r\nThe 2nd Quartile = 130.0\r\nThe 3rd Quartile = 160.0\r\nThe result is = 30.0<\/pre>\nApproach:<\/strong><\/p>\n\nImport the numpy library as np using the import function.<\/li>\n Give the lower limit as user input using the int(input()) function and store it in a variable.<\/li>\n Give the upper limit as user input using the int(input()) function and store it in another variable.<\/li>\n \n\n
Give the step size as user input using the int(input()) function and store it in another variable.<\/div>\n<\/div>\n<\/li>\n
Pass the lower limit, upper limit, and step size with some random numbers to the range() function and convert it into a list using the list() function. It is considered as the dataset.<\/li>\n Store it in a variable.<\/li>\n Pass the above dataset,\u00a0 0.25\u00a0 deviation as the arguments to the quantile() function and store it in a variable.<\/li>\n Pass the above dataset,\u00a0 0.50\u00a0 deviation as the arguments to the quantile() function and store it in another variable.<\/li>\n Pass the above dataset,\u00a0 0.75 deviation as the arguments to the quantile() function and store it in another variable.<\/li>\n Print the above three variables i.e, quartile1, quartile1, and quartile1.<\/li>\n Create a function say quartile_deviatn() which accepts two numbers as the arguments and returns half of the difference of two numbers.<\/li>\n Inside the function, return the value half of the difference of two numbers ((x – y)\/2).<\/li>\n Pass the quartile3, quartile1 as arguments to the quartile_deviatn() function and store it in a variable.<\/li>\n Print the above result.<\/li>\n The Exit of the Program.<\/li>\n<\/ul>\nBelow is the implementation:<\/strong><\/p>\n# Import the numpy library as np using the import function.\r\nimport numpy as np\r\n# Give the lower limit as user input using the int(input()) function and\r\n# store it in a variable.\r\ngvnlwr_lmt = int(input(\"Enter some random number = \"))\r\n# Give the upper limit as user input using the int(input()) function and\r\n# store it in another variable.\r\ngvnupr_lmt = int(input(\"Enter some random number = \"))\r\n# Give the step size as user input using the int(input()) function and\r\n# store it in another variable.\r\ngvn_step = int(input(\"Enter some random number = \"))\r\n# Pass the lower limit, upper limit, and step size with some random numbers to the\r\n# range() function and convert it into a list using the list() function.\r\n# It is considered as the dataset.\r\n# Store it in a variable.\r\ngvn_dataset = list(range(gvnlwr_lmt, gvnupr_lmt, gvn_step))\r\n# Pass the above dataset,\u00a0 0.25\u00a0 deviation as the arguments to the quantile()\r\n# function and store it in a variable.\r\nquartle_1 = np.quantile(gvn_dataset, 0.25)\r\n# Pass the above dataset,\u00a0 0.50\u00a0 deviation as the arguments to the quantile()\r\n# function and store it in another variable.\r\nquartle_2 = np.quantile(gvn_dataset, 0.50)\r\n# Pass the above dataset,\u00a0 0.75 deviation as the arguments to the quantile()\r\n# function and store it in another variable.\r\nquartle_3 = np.quantile(gvn_dataset, 0.75)\r\n# Print the above three variables i.e, quartile1, quartile1, and quartile1.\r\nprint(\"The 1st Quartile = \", quartle_1)\r\nprint(\"The 2nd Quartile = \", quartle_2)\r\nprint(\"The 3rd Quartile = \", quartle_3)\r\n# Create a function say quartile_deviatn() which accepts two numbers as the\r\n# arguments and returns half of the difference of two numbers.\r\n\r\n\r\ndef quartile_deviatn(x, y):\r\n # Inside the function, return the value half of the difference of two numbers\r\n # ((x - y)\/2).\r\n return (x - y)\/2\r\n\r\n\r\n# Pass the quartile3, quartile1 as arguments to the quartile_deviatn() function\r\n# and store it in a variable.\r\nrslt = quartile_deviatn(quartle_3, quartle_1)\r\n# Print the above result.\r\nprint(\"The result is = \", rslt)\r\n<\/pre>\nOutput:<\/strong><\/p>\nEnter some random number = 45 \r\nEnter some random number = 90 \r\nEnter some random number = 5 \r\nThe 1st Quartile = 55.0 \r\nThe 2nd Quartile = 65.0 \r\nThe 3rd Quartile = 75.0 \r\nThe result is = 10.0<\/pre>\n <\/p>\n","protected":false},"excerpt":{"rendered":"
Quartile Deviation The quartile deviation is the absolute measure of dispersion. It is computed by dividing the difference between the top and bottom quartiles in half. The quartile deviation is the absolute measure of dispersion, where dispersion is the amount by which the values in the distribution differ from the mean value. Even if there …<\/p>\n
Python Program for Quartile Deviation<\/span> Read More »<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"yoast_head":"\nPython Program for Quartile Deviation - Python Programs<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n