{"id":41175,"date":"2025-08-06T08:41:50","date_gmt":"2025-08-06T05:41:50","guid":{"rendered":"https:\/\/goit.global\/?post_type=articles&#038;p=41175"},"modified":"2026-04-30T14:40:48","modified_gmt":"2026-04-30T11:40:48","slug":"okruhlennia-chysel-v-python","status":"publish","type":"articles","link":"https:\/\/goit.global\/ua\/articles\/okruhlennia-chysel-v-python\/","title":{"rendered":"\u041e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u044f \u0432 Python: \u044f\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u0456\u0431 \u0456 \u043a\u043e\u043b\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438"},"content":{"rendered":"<p>&#1040; &#1103;&#1082;&#1097;&#1086; &#1090;&#1080; &#1093;&#1086;&#1095;&#1077;&#1096; &#1086;&#1089;&#1074;&#1086;&#1111;&#1090;&#1080; Python &laquo;&#1079; &#1085;&#1091;&#1083;&#1103;&raquo;, &#1079;&#1074;&#1077;&#1088;&#1085;&#1080; &#1091;&#1074;&#1072;&#1075;&#1091; &#1085;&#1072; <a href=\"https:\/\/goit.global\/ua\/courses\/python-ds\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\" target=\"_blank\" rel=\"noopener\">&#1072;&#1082;&#1090;&#1091;&#1072;&#1083;&#1100;&#1085;&#1080;&#1081; &#1082;&#1091;&#1088;&#1089; GoIT<\/a>, &#1076;&#1077; &#1090;&#1080; &#1086;&#1090;&#1088;&#1080;&#1084;&#1072;&#1108;&#1096; &#1091;&#1089;&#1110; &#1085;&#1077;&#1086;&#1073;&#1093;&#1110;&#1076;&#1085;&#1110; &#1079;&#1085;&#1072;&#1085;&#1085;&#1103; &#1076;&#1083;&#1103; &#1089;&#1090;&#1072;&#1088;&#1090;&#1091; &#1074; IT!<\/p>\n<p><a href=\"https:\/\/python-m-lp-ua.goit.global\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\"><picture id=\"gb-banner-2j4r47w4gjg\" class=\"gb-banner\" data-gb-banner=\"true\"><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004756\/1280-Python.jpg\" media=\"(min-width:1280px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004754\/1024-Python.jpg\" media=\"(min-width:1024px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004752\/768-Python.jpg\" media=\"(min-width:768px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004750\/480x159-Python.jpg\" media=\"(min-width:480px)\"><\/source><\/picture><\/a>\n<\/p>\n<h2>int() &#1110; round(): &#1073;&#1072;&#1079;&#1086;&#1074;&#1110; &#1084;&#1077;&#1090;&#1086;&#1076;&#1080; &#1076;&#1083;&#1103; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1095;&#1080;&#1089;&#1077;&#1083;<\/h2>\n<p>\n&#1053;&#1072;&#1081;&#1087;&#1088;&#1086;&#1089;&#1090;&#1110;&#1096;&#1080;&#1081; &#1089;&#1087;&#1086;&#1089;&#1110;&#1073;, &#1103;&#1082;&#1080;&#1081; &#1089;&#1087;&#1072;&#1076;&#1072;&#1108; &#1085;&#1072; &#1076;&#1091;&#1084;&#1082;&#1091; &ndash; &#1094;&#1077; &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1074;&#1072;&#1090;&#1080; <strong>int<\/strong> &#1055;&#1072;&#1081;&#1090;&#1086;&#1085;. &#1062;&#1103; &#1074;&#1073;&#1091;&#1076;&#1086;&#1074;&#1072;&#1085;&#1072; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1103; &#1087;&#1088;&#1086;&#1089;&#1090;&#1086; &#1074;&#1110;&#1076;&#1082;&#1080;&#1076;&#1072;&#1108; &#1076;&#1088;&#1086;&#1073;&#1086;&#1074;&#1091; &#1095;&#1072;&#1089;&#1090;&#1080;&#1085;&#1091; &#1095;&#1080;&#1089;&#1083;&#1072;, &#1085;&#1077; &#1079;&#1072;&#1084;&#1080;&#1089;&#1083;&#1102;&#1102;&#1095;&#1080;&#1089;&#1100; &#1087;&#1088;&#1086; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072; &#1084;&#1072;&#1090;&#1077;&#1084;&#1072;&#1090;&#1080;&#1095;&#1085;&#1086;&#1075;&#1086; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103;.<\/p>\n<p><em>x = 5.9<\/em><\/p>\n<p><em>print(int(x))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 5<\/em><\/p>\n<p>&#1071;&#1082; &#1073;&#1072;&#1095;&#1080;&#1096;, int Python &#1094;&#1077; &laquo;&#1075;&#1088;&#1091;&#1073;&#1080;&#1081;&raquo; &#1089;&#1087;&#1086;&#1089;&#1110;&#1073;, &#1103;&#1082;&#1080;&#1081; &#1085;&#1077; &#1074;&#1088;&#1072;&#1093;&#1086;&#1074;&#1091;&#1108; &#1084;&#1072;&#1090;&#1077;&#1084;&#1072;&#1090;&#1080;&#1095;&#1085;&#1110; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072;. &#1058;&#1086;&#1084;&#1091; &#1074;&#1110;&#1085; &#1085;&#1077; &#1079;&#1072;&#1074;&#1078;&#1076;&#1080; &#1087;&#1110;&#1076;&#1093;&#1086;&#1076;&#1080;&#1090;&#1100; &#1076;&#1083;&#1103; &#1090;&#1086;&#1095;&#1085;&#1080;&#1093; &#1088;&#1086;&#1079;&#1088;&#1072;&#1093;&#1091;&#1085;&#1082;&#1110;&#1074;.<\/p>\n<p>&#1044;&#1083;&#1103; &#1094;&#1100;&#1086;&#1075;&#1086; &#1110;&#1089;&#1085;&#1091;&#1108; &#1074;&#1073;&#1091;&#1076;&#1086;&#1074;&#1072;&#1085;&#1072; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1103; <strong>round<\/strong> Python. &#1042;&#1086;&#1085;&#1072; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1103;&#1108; &#1095;&#1080;&#1089;&#1083;&#1086; &#1076;&#1086; &#1085;&#1072;&#1081;&#1073;&#1083;&#1080;&#1078;&#1095;&#1086;&#1075;&#1086; &#1094;&#1110;&#1083;&#1086;&#1075;&#1086;, &#1072; &#1103;&#1082;&#1097;&#1086; &#1076;&#1088;&#1086;&#1073;&#1086;&#1074;&#1072; &#1095;&#1072;&#1089;&#1090;&#1080;&#1085;&#1072; &#1076;&#1086;&#1088;&#1110;&#1074;&#1085;&#1102;&#1108; 0.5, &#1090;&#1086; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1103;&#1108; &#1076;&#1086; &#1085;&#1072;&#1081;&#1073;&#1083;&#1080;&#1078;&#1095;&#1086;&#1075;&#1086; &#1087;&#1072;&#1088;&#1085;&#1086;&#1075;&#1086; &#1095;&#1080;&#1089;&#1083;&#1072;. &#1062;&#1077; &#1090;&#1072;&#1082; &#1079;&#1074;&#1072;&#1085;&#1077; &laquo;&#1073;&#1072;&#1085;&#1082;&#1110;&#1074;&#1089;&#1100;&#1082;&#1077;&raquo; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103;. round python3 &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1108; &#1089;&#1072;&#1084;&#1077; &#1090;&#1072;&#1082;&#1080;&#1081; &#1084;&#1077;&#1090;&#1086;&#1076;.<\/p>\n<p><em># &#1054;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1076;&#1086; &#1085;&#1072;&#1081;&#1073;&#1083;&#1080;&#1078;&#1095;&#1086;&#1075;&#1086; &#1087;&#1072;&#1088;&#1085;&#1086;&#1075;&#1086;<\/em><\/p>\n<p><em>print(round(2.5))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 2<\/em><\/p>\n<p><em>print(round(3.5))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 4<\/em><\/p>\n<p><em># &#1054;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1076;&#1086; &#1094;&#1110;&#1083;&#1086;&#1075;&#1086;<\/em><\/p>\n<p><em>print(round(5.7))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 6<\/em><\/p>\n<p>&#1058;&#1080; &#1090;&#1072;&#1082;&#1086;&#1078; &#1084;&#1086;&#1078;&#1077;&#1096; &#1074;&#1082;&#1072;&#1079;&#1072;&#1090;&#1080; &#1082;&#1110;&#1083;&#1100;&#1082;&#1110;&#1089;&#1090;&#1100; &#1079;&#1085;&#1072;&#1082;&#1110;&#1074; &#1087;&#1110;&#1089;&#1083;&#1103; &#1082;&#1086;&#1084;&#1080;. &#1053;&#1072;&#1087;&#1088;&#1080;&#1082;&#1083;&#1072;&#1076;, &#1097;&#1086;&#1073; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1080;&#1090;&#1080; &#1076;&#1086; &#1076;&#1077;&#1089;&#1103;&#1090;&#1080;&#1093;, &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1081; &#1076;&#1088;&#1091;&#1075;&#1080;&#1081; &#1072;&#1088;&#1075;&#1091;&#1084;&#1077;&#1085;&#1090;.<\/p>\n<p><em>x = 3.14159<\/em><\/p>\n<p><em>print(round(x, 1))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 3.1<\/em><\/p>\n<p><em>print(round(x, 2))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 3.14<\/em><\/p>\n<p><em>print(round(x, 3))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 3.142<\/em><\/p>\n<p>&#1071;&#1082; &#1073;&#1072;&#1095;&#1080;&#1096;, <a href=\"https:\/\/goit.global\/ua\/articles\/shcho-take-python-i-dlia-choho-vin-potriben\/\" target=\"_blank\" rel=\"noopener\">Python<\/a> &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1076;&#1086; &#1089;&#1086;&#1090;&#1080;&#1093; &#1072;&#1073;&#1086; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1076;&#1086; &#1090;&#1080;&#1089;&#1103;&#1095;&#1085;&#1080;&#1093; &ndash; &#1094;&#1077; &#1079;&#1086;&#1074;&#1089;&#1110;&#1084; &#1085;&#1077; &#1087;&#1088;&#1086;&#1073;&#1083;&#1077;&#1084;&#1072;. &#1059;&#1089;&#1110; &#1094;&#1110; &#1086;&#1087;&#1077;&#1088;&#1072;&#1094;&#1110;&#1111; &#1074;&#1080;&#1082;&#1086;&#1085;&#1091;&#1102;&#1090;&#1100;&#1089;&#1103; &#1079;&#1072; &#1089;&#1090;&#1072;&#1085;&#1076;&#1072;&#1088;&#1090;&#1085;&#1080;&#1084;&#1080; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072;&#1084;&#1080;. &#1058;&#1072;&#1082;&#1086;&#1078; &#1079;&#1072; &#1076;&#1086;&#1087;&#1086;&#1084;&#1086;&#1075;&#1086;&#1102; <strong>round()<\/strong> &#1084;&#1086;&#1078;&#1085;&#1072; &#1089;&#1082;&#1086;&#1088;&#1086;&#1090;&#1080;&#1090;&#1080; &#1095;&#1080;&#1089;&#1083;&#1086; &#1076;&#1086; &#1087;&#1086;&#1090;&#1088;&#1110;&#1073;&#1085;&#1086;&#1111; &#1082;&#1110;&#1083;&#1100;&#1082;&#1086;&#1089;&#1090;&#1110; &#1079;&#1085;&#1072;&#1082;&#1110;&#1074;.<\/p>\n<p><a href=\"https:\/\/python-m-lp-ua.goit.global\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\"><picture id=\"gb-banner-e1vfdikwktq\" class=\"gb-banner\" data-gb-banner=\"true\"><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004756\/1280-Python.jpg\" media=\"(min-width:1280px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004754\/1024-Python.jpg\" media=\"(min-width:1024px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004752\/768-Python.jpg\" media=\"(min-width:768px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004750\/480x159-Python.jpg\" media=\"(min-width:480px)\"><\/source><\/picture><\/a>\n<\/p>\n<h2>&#1052;&#1086;&#1076;&#1091;&#1083;&#1100; math: &#1090;&#1086;&#1095;&#1085;&#1080;&#1081; &#1082;&#1086;&#1085;&#1090;&#1088;&#1086;&#1083;&#1100; &#1085;&#1072;&#1076; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103;&#1084;<\/h2>\n<p>\n&#1071;&#1082;&#1097;&#1086; &#1090;&#1086;&#1073;&#1110; &#1087;&#1086;&#1090;&#1088;&#1110;&#1073;&#1077;&#1085; &#1087;&#1086;&#1074;&#1085;&#1080;&#1081; &#1082;&#1086;&#1085;&#1090;&#1088;&#1086;&#1083;&#1100;, &#1090;&#1086; &#1074;&#1072;&#1088;&#1090;&#1086; &#1087;&#1110;&#1076;&#1082;&#1083;&#1102;&#1095;&#1080;&#1090;&#1080; &#1084;&#1086;&#1076;&#1091;&#1083;&#1100; <strong>math<\/strong>. &#1053;&#1072;&#1087;&#1077;&#1074;&#1085;&#1086; &#1091; &#1090;&#1077;&#1073;&#1077; &#1074; &#1075;&#1086;&#1083;&#1086;&#1074;&#1110; &#1074;&#1078;&#1077; &#1074;&#1080;&#1085;&#1080;&#1082;&#1083;&#1086; &#1087;&#1080;&#1090;&#1072;&#1085;&#1085;&#1103;: import math Python &#1097;&#1086; &#1094;&#1077;? &#1062;&#1077; &#1082;&#1086;&#1084;&#1072;&#1085;&#1076;&#1072;, &#1103;&#1082;&#1072; &#1087;&#1110;&#1076;&#1082;&#1083;&#1102;&#1095;&#1072;&#1108; &#1074;&#1073;&#1091;&#1076;&#1086;&#1074;&#1072;&#1085;&#1091; &#1073;&#1110;&#1073;&#1083;&#1110;&#1086;&#1090;&#1077;&#1082;&#1091; &#1079; &#1076;&#1086;&#1076;&#1072;&#1090;&#1082;&#1086;&#1074;&#1080;&#1084;&#1080; &#1084;&#1072;&#1090;&#1077;&#1084;&#1072;&#1090;&#1080;&#1095;&#1085;&#1080;&#1084;&#1080; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1103;&#1084;&#1080;.<\/p>\n<p>&#1065;&#1086;&#1073; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1080;&#1090;&#1080; &#1074; &#1073;&#1110;&#1083;&#1100;&#1096;&#1091; &#1089;&#1090;&#1086;&#1088;&#1086;&#1085;&#1091; <a href=\"https:\/\/goit.global\/ua\/articles\/khto-takyy-python-rozrobnyk-i-chym-vin-zaymaietsia\/\" target=\"_blank\" rel=\"noopener\">Python<\/a>, &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1081; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1102; <strong>math.ceil()<\/strong>. &#1031;&#1111; &#1085;&#1072;&#1079;&#1074;&#1072; &#1087;&#1086;&#1093;&#1086;&#1076;&#1080;&#1090;&#1100; &#1074;&#1110;&#1076; &#1072;&#1085;&#1075;&#1083;&#1110;&#1081;&#1089;&#1100;&#1082;&#1086;&#1075;&#1086; &#1089;&#1083;&#1086;&#1074;&#1072; &laquo;ceiling&raquo;, &#1097;&#1086; &#1073;&#1091;&#1082;&#1074;&#1072;&#1083;&#1100;&#1085;&#1086; &#1087;&#1077;&#1088;&#1077;&#1082;&#1083;&#1072;&#1076;&#1072;&#1108;&#1090;&#1100;&#1089;&#1103; &#1103;&#1082; &laquo;&#1089;&#1090;&#1077;&#1083;&#1103;&raquo;.<\/p>\n<p><em>import math<\/em><\/p>\n<p><em># &#1055;&#1088;&#1072;&#1082;&#1090;&#1080;&#1095;&#1085;&#1080;&#1081; &#1082;&#1077;&#1081;&#1089;: &#1088;&#1086;&#1079;&#1088;&#1072;&#1093;&#1091;&#1074;&#1072;&#1090;&#1080; &#1082;&#1110;&#1083;&#1100;&#1082;&#1110;&#1089;&#1090;&#1100; &#1091;&#1087;&#1072;&#1082;&#1086;&#1074;&#1086;&#1082;, &#1097;&#1086;&#1073; &#1074;&#1080;&#1089;&#1090;&#1072;&#1095;&#1080;&#1083;&#1086; &#1085;&#1072; &#1074;&#1089;&#1110; 10.2 &#1082;&#1075; &#1087;&#1088;&#1086;&#1076;&#1091;&#1082;&#1090;&#1091;<\/em><\/p>\n<p><em>total_weight = 10.2<\/em><\/p>\n<p><em>package_size = 1<\/em><\/p>\n<p><em>packages_needed = math.ceil(total_weight \/ package_size)<\/em><\/p>\n<p><em>print(f&#8221;&#1055;&#1086;&#1090;&#1088;&#1110;&#1073;&#1085;&#1086; &#1091;&#1087;&#1072;&#1082;&#1086;&#1074;&#1086;&#1082;: {packages_needed}&#8221;) # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; &#8220;&#1055;&#1086;&#1090;&#1088;&#1110;&#1073;&#1085;&#1086; &#1091;&#1087;&#1072;&#1082;&#1086;&#1074;&#1086;&#1082;: 11&#8221;<\/em><\/p>\n<figure id=\"attachment_41159\" aria-describedby=\"caption-attachment-41159\" style=\"width: 750px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-41159\" src=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2025\/08\/05170019\/Kak-okruhlyt-chysla-v-Python.png\" alt=\"\" width=\"750\" height=\"447\" srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2025\/08\/05170019\/Kak-okruhlyt-chysla-v-Python.png 1424w, https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2025\/08\/05170019\/Kak-okruhlyt-chysla-v-Python-300x179.png 300w, https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2025\/08\/05170019\/Kak-okruhlyt-chysla-v-Python-1024x610.png 1024w, https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2025\/08\/05170019\/Kak-okruhlyt-chysla-v-Python-768x457.png 768w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><figcaption id=\"caption-attachment-41159\" class=\"wp-caption-text\"><em><span class=\"jCAhz ChMk0b\"><span class=\"ryNqvb\">&#1063;&#1080; &#1087;&#1083;&#1072;&#1085;&#1091;&#1108;&#1096; &#1089;&#1090;&#1072;&#1088;&#1090;&#1091;&#1074;&#1072;&#1090;&#1080; &#1074; &#1040;&#1081;&#1058;&#1110;?<\/span><\/span> <span class=\"jCAhz ChMk0b\"><span class=\"ryNqvb\">&#1055;&#1088;&#1080;&#1093;&#1086;&#1076;&#1100; &#1085;&#1072; <a href=\"https:\/\/goit.global\/ua\/newcomers\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\" target=\"_blank\" rel=\"noopener\">&#1073;&#1077;&#1079;&#1087;&#1083;&#1072;&#1090;&#1085;&#1110; &#1084;&#1072;&#1088;&#1072;&#1092;&#1086;&#1085;&#1080;<\/a> &#1090;&#1072; <a href=\"https:\/\/goit.global\/ua\/courses\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\" target=\"_blank\" rel=\"noopener\">&#1082;&#1091;&#1088;&#1089;&#1080; GoIT<\/a>!<\/span><\/span><\/em><\/figcaption><\/figure>\n<p>&#1071;&#1082;&#1097;&#1086; &#1078; &#1090;&#1086;&#1073;&#1110; &#1087;&#1086;&#1090;&#1088;&#1110;&#1073;&#1085;&#1077; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1074; &#1084;&#1077;&#1085;&#1096;&#1091; &#1089;&#1090;&#1086;&#1088;&#1086;&#1085;&#1091; Python, &#1090;&#1086; &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1081; <strong>math.floor()<\/strong> &ndash; &#1074;&#1110;&#1076; &#1089;&#1083;&#1086;&#1074;&#1072; &laquo;floor&raquo; &#1079; <a href=\"https:\/\/goit.global\/ua\/articles\/yak-vyvchyty-anhliysku-samostiyno-i-proyty-spivbesidu-na-robotu\/\" target=\"_blank\" rel=\"noopener\">&#1072;&#1085;&#1075;&#1083;&#1110;&#1081;&#1089;&#1100;&#1082;&#1086;&#1111;<\/a>, &#1097;&#1086; &#1087;&#1077;&#1088;&#1077;&#1082;&#1083;&#1072;&#1076;&#1072;&#1108;&#1090;&#1100;&#1089;&#1103; &#1103;&#1082; &laquo;&#1087;&#1110;&#1076;&#1083;&#1086;&#1075;&#1072;&raquo;.<\/p>\n<p><em>import math<\/em><\/p>\n<p><em># &#1055;&#1088;&#1072;&#1082;&#1090;&#1080;&#1095;&#1085;&#1080;&#1081; &#1082;&#1077;&#1081;&#1089;: &#1088;&#1086;&#1079;&#1088;&#1072;&#1093;&#1091;&#1074;&#1072;&#1090;&#1080;, &#1089;&#1082;&#1110;&#1083;&#1100;&#1082;&#1080; &#1087;&#1086;&#1074;&#1085;&#1080;&#1093; &#1087;&#1072;&#1095;&#1086;&#1082; &#1095;&#1072;&#1102; &#1087;&#1086; 500 &#1075;&#1088;&#1072;&#1084;&#1110;&#1074; &#1084;&#1086;&#1078;&#1085;&#1072; &#1079;&#1088;&#1086;&#1073;&#1080;&#1090;&#1080; &#1079; 2.7 &#1082;&#1075; &#1095;&#1072;&#1102;<\/em><\/p>\n<p><em>tea_kg = 2.7<\/em><\/p>\n<p><em>package_kg = 0.5<\/em><\/p>\n<p><em>packages_made = math.floor(tea_kg \/ package_kg)<\/em><\/p>\n<p><em>print(f&#8221;&#1042;&#1080;&#1081;&#1076;&#1077; &#1087;&#1086;&#1074;&#1085;&#1080;&#1093; &#1087;&#1072;&#1095;&#1086;&#1082;: {packages_made}&#8221;) # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; &#8220;&#1042;&#1080;&#1081;&#1076;&#1077; &#1087;&#1086;&#1074;&#1085;&#1080;&#1093; &#1087;&#1072;&#1095;&#1086;&#1082;: 5&#8221;<\/em><\/p>\n<p>&#1058;&#1072;&#1082;&#1086;&#1078; &#1108; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1103; Python <strong>trunc<\/strong>, &#1103;&#1082;&#1072; &#1087;&#1088;&#1072;&#1094;&#1102;&#1108; &#1103;&#1082; int() &ndash; &#1087;&#1088;&#1086;&#1089;&#1090;&#1086; &#1074;&#1110;&#1076;&#1082;&#1080;&#1076;&#1072;&#1108; &#1076;&#1088;&#1086;&#1073;&#1086;&#1074;&#1091; &#1095;&#1072;&#1089;&#1090;&#1080;&#1085;&#1091;.<\/p>\n<p><em>import math<\/em><\/p>\n<p><em>print(math.trunc(4.9)) &nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 4<\/em><\/p>\n<p><em>print(math.trunc(-4.9))&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; -4<\/em>\n<\/p>\n<h2>&#1055;&#1088;&#1072;&#1082;&#1090;&#1080;&#1095;&#1085;&#1110; &#1087;&#1086;&#1088;&#1072;&#1076;&#1080; &#1090;&#1072; &#1083;&#1072;&#1081;&#1092;&#1093;&#1072;&#1082;&#1080;<\/h2>\n<p>\n&#1047;&#1085;&#1072;&#1082; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1074; <a href=\"https:\/\/goit.global\/ua\/articles\/biblioteky-python-dlia-data-science\/\" target=\"_blank\" rel=\"noopener\">Python<\/a> &#1079;&#1072;&#1083;&#1077;&#1078;&#1080;&#1090;&#1100; &#1074;&#1110;&#1076; &#1086;&#1073;&#1088;&#1072;&#1085;&#1086;&#1111; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1111;. &#1055;&#1072;&#1084;&rsquo;&#1103;&#1090;&#1072;&#1081;, &#1097;&#1086; <strong>int()<\/strong> &#1110; <strong>math.trunc()<\/strong> &#1079;&#1072;&#1074;&#1078;&#1076;&#1080; &laquo;&#1088;&#1091;&#1073;&#1072;&#1102;&#1090;&#1100;&raquo; &#1076;&#1088;&#1086;&#1073;&#1086;&#1074;&#1091; &#1095;&#1072;&#1089;&#1090;&#1080;&#1085;&#1091;, &#1072; <strong>round()<\/strong>, <strong>ceil()<\/strong> &#1110; <strong>floor()<\/strong> &#1087;&#1088;&#1072;&#1094;&#1102;&#1102;&#1090;&#1100; &#1079;&#1072; &#1088;&#1110;&#1079;&#1085;&#1080;&#1084;&#1080; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072;&#1084;&#1080;. &#1065;&#1077; &#1086;&#1076;&#1080;&#1085; &#1082;&#1086;&#1088;&#1080;&#1089;&#1085;&#1080;&#1081; &#1083;&#1072;&#1081;&#1092;&#1093;&#1072;&#1082; &ndash; &#1094;&#1077; &#1092;&#1086;&#1088;&#1084;&#1072;&#1090;&#1086;&#1074;&#1072;&#1085;&#1080;&#1081; &#1074;&#1080;&#1074;&#1110;&#1076; &#1079;&#1072; &#1076;&#1086;&#1087;&#1086;&#1084;&#1086;&#1075;&#1086;&#1102; <strong>f-string<\/strong>. &#1062;&#1077; &#1076;&#1086;&#1079;&#1074;&#1086;&#1083;&#1103;&#1108; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1080;&#1090;&#1080; &#1095;&#1080;&#1089;&#1083;&#1086; Python &#1087;&#1088;&#1080; &#1074;&#1080;&#1074;&#1086;&#1076;&#1110;, &#1085;&#1077; &#1079;&#1084;&#1110;&#1085;&#1102;&#1102;&#1095;&#1080; &#1089;&#1072;&#1084;&#1091; &#1079;&#1084;&#1110;&#1085;&#1085;&#1091;.<\/p>\n<p><em>pi = 3.14159265<\/em><\/p>\n<p><em>print(f&#8217;&#1063;&#1080;&#1089;&#1083;&#1086; pi &#1079; &#1090;&#1086;&#1095;&#1085;&#1110;&#1089;&#1090;&#1102; &#1076;&#1086; &#1076;&#1074;&#1086;&#1093; &#1079;&#1085;&#1072;&#1082;&#1110;&#1074;: {pi:.2f}&#8217;)&nbsp; # &#1042;&#1080;&#1074;&#1077;&#1076;&#1077; 3.14<\/em><\/p>\n<p>&#1044;&#1086; &#1088;&#1077;&#1095;&#1110;, &#1103;&#1082;&#1097;&#1086; &#1090;&#1086;&#1073;&#1110; &#1087;&#1086;&#1090;&#1088;&#1110;&#1073;&#1085;&#1110; &#1090;&#1086;&#1095;&#1085;&#1110; &#1092;&#1110;&#1085;&#1072;&#1085;&#1089;&#1086;&#1074;&#1110; &#1088;&#1086;&#1079;&#1088;&#1072;&#1093;&#1091;&#1085;&#1082;&#1080;, &#1082;&#1088;&#1072;&#1097;&#1077; &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1074;&#1072;&#1090;&#1080; &#1084;&#1086;&#1076;&#1091;&#1083;&#1100; <strong>decimal<\/strong>. &#1042;&#1110;&#1085; &#1076;&#1086;&#1087;&#1086;&#1084;&#1072;&#1075;&#1072;&#1108; &#1091;&#1085;&#1080;&#1082;&#1085;&#1091;&#1090;&#1080; &#1085;&#1077;&#1090;&#1086;&#1095;&#1085;&#1086;&#1089;&#1090;&#1077;&#1081;, &#1074;&#1083;&#1072;&#1089;&#1090;&#1080;&#1074;&#1080;&#1093; &#1095;&#1080;&#1089;&#1083;&#1072;&#1084; &#1110;&#1079; &#1087;&#1083;&#1072;&#1074;&#1091;&#1095;&#1086;&#1102; &#1082;&#1086;&#1084;&#1086;&#1102; (float).<br \/>\n&#1058;&#1072;&#1082;&#1086;&#1078; &#1074;&#1072;&#1088;&#1090;&#1086; &#1079;&#1075;&#1072;&#1076;&#1072;&#1090;&#1080;, &#1097;&#1086; &#1076;&#1110;&#1083;&#1077;&#1085;&#1085;&#1103; &#1074; &#1055;&#1072;&#1081;&#1090;&#1086;&#1085;&#1110; (\/) &#1079;&#1072;&#1074;&#1078;&#1076;&#1080; &#1076;&#1072;&#1108; float, &#1072; &#1076;&#1110;&#1083;&#1077;&#1085;&#1085;&#1103; &#1073;&#1077;&#1079; &#1086;&#1089;&#1090;&#1072;&#1095;&#1110; <a href=\"https:\/\/goit.global\/ua\/articles\/yak-staty-python-data-scientist-z-nulia\/\" target=\"_blank\" rel=\"noopener\">Python<\/a> (\/\/) &ndash; &#1094;&#1110;&#1083;&#1077; &#1095;&#1080;&#1089;&#1083;&#1086;.<\/p>\n<p><a href=\"https:\/\/python-m-lp-ua.goit.global\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\"><picture id=\"gb-banner-87zzpcs5oko\" class=\"gb-banner\" data-gb-banner=\"true\"><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004756\/1280-Python.jpg\" media=\"(min-width:1280px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004754\/1024-Python.jpg\" media=\"(min-width:1024px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004752\/768-Python.jpg\" media=\"(min-width:768px)\"><\/source><source srcset=\"https:\/\/web-dev-goit.s3.eu-north-1.amazonaws.com\/app\/uploads\/2023\/12\/19004750\/480x159-Python.jpg\" media=\"(min-width:480px)\"><\/source><\/picture><\/a>\n<\/p>\n<h2>&#1055;&#1086;&#1087;&#1091;&#1083;&#1103;&#1088;&#1085;&#1110; &#1087;&#1080;&#1090;&#1072;&#1085;&#1085;&#1103; &#1087;&#1088;&#1086; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1074; &#1055;&#1072;&#1081;&#1090;&#1086;&#1085;<\/h2>\n<p>\n&#1058;&#1091;&#1090; &#1074;&#1110;&#1076;&#1087;&#1086;&#1074;&#1110;&#1084;&#1086; &#1085;&#1072; &#1085;&#1072;&#1081;&#1087;&#1086;&#1087;&#1091;&#1083;&#1103;&#1088;&#1085;&#1110;&#1096;&#1110; &#1087;&#1080;&#1090;&#1072;&#1085;&#1085;&#1103;, &#1103;&#1082;&#1110; &#1074;&#1080;&#1085;&#1080;&#1082;&#1072;&#1102;&#1090;&#1100; &#1091; &#1085;&#1086;&#1074;&#1072;&#1095;&#1082;&#1110;&#1074;.\n<\/p>\n<h3>&#1071;&#1082; &#1091; &#1055;&#1072;&#1081;&#1090;&#1086;&#1085;&#1110; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1080;&#1090;&#1080; &#1095;&#1080;&#1089;&#1083;&#1086; &#1076;&#1086; &#1076;&#1077;&#1089;&#1103;&#1090;&#1080;&#1093;?<\/h3>\n<p>\n&#1042;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1081; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1102; <strong>round()<\/strong> &#1110;&#1079; &#1076;&#1088;&#1091;&#1075;&#1080;&#1084; &#1072;&#1088;&#1075;&#1091;&#1084;&#1077;&#1085;&#1090;&#1086;&#1084;: <em>round(12.345, 1) -&gt; 12.3<\/em>.\n<\/p>\n<h3>&#1063;&#1080;&#1084; &#1074;&#1110;&#1076;&#1088;&#1110;&#1079;&#1085;&#1103;&#1108;&#1090;&#1100;&#1089;&#1103; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1074; &#1055;&#1072;&#1081;&#1090;&#1086;&#1085;&#1110; &#1074;&#1110;&#1076; int()?<\/h3>\n<p><strong>round()<\/strong><\/p>\n<p> &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1103;&#1108; &#1079;&#1072; &#1084;&#1072;&#1090;&#1077;&#1084;&#1072;&#1090;&#1080;&#1095;&#1085;&#1080;&#1084;&#1080; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072;&#1084;&#1080;, &#1072; <strong>int()<\/strong> &#1087;&#1088;&#1086;&#1089;&#1090;&#1086; &#1074;&#1110;&#1076;&#1082;&#1080;&#1076;&#1072;&#1108; &#1076;&#1088;&#1086;&#1073;&#1086;&#1074;&#1091; &#1095;&#1072;&#1089;&#1090;&#1080;&#1085;&#1091;.\n<\/p>\n<h3>&#1071;&#1082; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1080;&#1090;&#1080; &#1074; &#1073;&#1110;&#1083;&#1100;&#1096;&#1091; &#1089;&#1090;&#1086;&#1088;&#1086;&#1085;&#1091; Python?<\/h3>\n<p>\n&#1044;&#1083;&#1103; &#1094;&#1100;&#1086;&#1075;&#1086; &#1074;&#1080;&#1082;&#1086;&#1088;&#1080;&#1089;&#1090;&#1086;&#1074;&#1091;&#1081; <strong>math.ceil()<\/strong>. &#1053;&#1072;&#1087;&#1088;&#1080;&#1082;&#1083;&#1072;&#1076;, <em>math.ceil(7.2) -&gt; 8<\/em>.\n<\/p>\n<h3>&#1065;&#1086; &#1090;&#1072;&#1082;&#1077; Python math floor?<\/h3>\n<p>\n&#1062;&#1077; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1103; &#1079; &#1084;&#1086;&#1076;&#1091;&#1083;&#1103; <strong>math<\/strong>, &#1103;&#1082;&#1072; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1103;&#1108; &#1095;&#1080;&#1089;&#1083;&#1086; &#1076;&#1086; &#1084;&#1077;&#1085;&#1096;&#1086;&#1075;&#1086; &#1094;&#1110;&#1083;&#1086;&#1075;&#1086;. <em>math.floor(7.9) -&gt; 7<\/em>.\n<\/p>\n<h3>&#1065;&#1086; &#1090;&#1072;&#1082;&#1077; Python round down?<\/h3>\n<p>\n&#1062;&#1077; &#1085;&#1077; &#1086;&#1092;&#1110;&#1094;&#1110;&#1081;&#1085;&#1072; &#1092;&#1091;&#1085;&#1082;&#1094;&#1110;&#1103;, &#1072;&#1083;&#1077; &#1079;&#1072;&#1079;&#1074;&#1080;&#1095;&#1072;&#1081; &#1087;&#1110;&#1076; &#1094;&#1080;&#1084; &#1084;&#1072;&#1102;&#1090;&#1100; &#1085;&#1072; &#1091;&#1074;&#1072;&#1079;&#1110; &#1086;&#1082;&#1088;&#1091;&#1075;&#1083;&#1077;&#1085;&#1085;&#1103; &#1074; &#1084;&#1077;&#1085;&#1096;&#1091; &#1089;&#1090;&#1086;&#1088;&#1086;&#1085;&#1091; &#1055;&#1072;&#1081;&#1090;&#1086;&#1085;, &#1090;&#1086;&#1073;&#1090;&#1086; <strong>math.floor()<\/strong>.<\/p>\n<p>&#1053;&#1072;&#1075;&#1086;&#1083;&#1086;&#1089;&#1080;&#1084;&#1086;, &#1097;&#1086; &#1075;&#1086;&#1083;&#1086;&#1074;&#1085;&#1077; &ndash; &#1094;&#1077; &#1087;&#1088;&#1072;&#1082;&#1090;&#1080;&#1082;&#1072;. &#1065;&#1086;&#1073; &#1085;&#1072;&#1074;&#1095;&#1080;&#1090;&#1080;&#1089;&#1103; &#1087;&#1080;&#1089;&#1072;&#1090;&#1080; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1100;&#1085;&#1080;&#1081; &#1082;&#1086;&#1076;, &#1087;&#1086;&#1090;&#1088;&#1110;&#1073;&#1085;&#1086; &#1073;&#1072;&#1075;&#1072;&#1090;&#1086; &#1087;&#1088;&#1072;&#1082;&#1090;&#1080;&#1082;&#1091;&#1074;&#1072;&#1090;&#1080;&#1089;&#1100;. &#1053;&#1072; <a href=\"https:\/\/goit.global\/ua\/courses\/python-ds\/?amp%3Butm_medium=articles&#038;amp%3Butm_campaign=41175\" target=\"_blank\" rel=\"noopener\">&#1082;&#1091;&#1088;&#1089;&#1072;&#1093; &#1055;&#1072;&#1081;&#1090;&#1086;&#1085; &#1074;&#1110;&#1076; GoIT<\/a> &#1090;&#1080; &#1079;&#1084;&#1086;&#1078;&#1077;&#1096; &#1086;&#1090;&#1088;&#1080;&#1084;&#1072;&#1090;&#1080; &#1074;&#1089;&#1110; &#1085;&#1077;&#1086;&#1073;&#1093;&#1110;&#1076;&#1085;&#1110; &#1079;&#1085;&#1072;&#1085;&#1085;&#1103; &#1090;&#1072; &#1085;&#1072;&#1074;&#1080;&#1095;&#1082;&#1080;!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u0432 Python \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u2013 \u0446\u0435 \u043f\u0440\u043e\u0441\u0442\u0456\u0448\u0435, \u043d\u0456\u0436 \u0437\u0434\u0430\u0454\u0442\u044c\u0441\u044f. \u0414\u0456\u0437\u043d\u0430\u0439\u0441\u044f, \u044f\u043a \u043f\u0440\u0430\u0446\u044e\u044e\u0442\u044c round(), int() \u0456 math, \u0456 \u043e\u0431\u0435\u0440\u0438 \u043d\u0430\u0439\u043a\u0440\u0430\u0449\u0438\u0439 \u0441\u043f\u043e\u0441\u0456\u0431. \u0427\u0438\u0442\u0430\u0439 \u043c\u0430\u0442\u0435\u0440\u0456\u0430\u043b GoIT!<\/p>\n","protected":false},"featured_media":41167,"menu_order":0,"template":"","meta":{"_acf_changed":false,"inline_featured_image":false},"categories":[12038],"tags":[],"class_list":["post-41175","articles","type-articles","status-publish","has-post-thumbnail","hentry","category-python-data-science"],"acf":[],"_links":{"self":[{"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/articles\/41175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/articles"}],"about":[{"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/types\/articles"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/media\/41167"}],"wp:attachment":[{"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/media?parent=41175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/categories?post=41175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/goit.global\/ua\/wp-json\/wp\/v2\/tags?post=41175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}