{"id":70,"date":"2021-07-20T04:56:56","date_gmt":"2021-07-20T04:56:56","guid":{"rendered":"http:\/\/www.programminginpython.com\/2023\/03\/30\/python-program-to-find-the-biggest-and-smallest-of-3-numbers\/"},"modified":"2023-05-14T14:11:21","modified_gmt":"2023-05-14T14:11:21","slug":"biggest-smallest-3-numbers","status":"publish","type":"post","link":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/","title":{"rendered":"Python Program to find the Biggest and Smallest of 3 numbers"},"content":{"rendered":"<p>Hello people, welcome to <a href=\"\/\" target=\"_blank\" rel=\"noopener\">Programming In Python<\/a>! Here I will discuss a simple Python program that finds the biggest and smallest of 3 numbers. Here we use the concept of <code>functions<\/code> in this program.<\/p>\n<p>We use two functions <code>biggest()<\/code> and <code>smallest()<\/code> to find the biggest number and smallest number respectively and finally return the result.<\/p>\n<p> https:\/\/www.youtube.com\/watch?v=Cz6q5u4iW5w&#8221;]<\/p>\n<p style=\"text-align: center;\"><strong>You can watch the video on YouTube <a href=\"https:\/\/www.youtube.com\/watch?v=Cz6q5u4iW5w\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a><\/strong><\/p>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/biggest_smallest_3numbers.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<div class=\"visualize_iframe\">\n<h4 class=\"post_h4\">Biggest and Smallest \u2013 Code Visualization<\/h4>\n<p><iframe src=\"https:\/\/pythontutor.com\/iframe-embed.html#code=number1%20%3D%20int%28input%28'Enter%20First%20number%20%3A%20'%29%29%0Anumber2%20%3D%20int%28input%28'Enter%20Second%20number%20%3A%20'%29%29%0Anumber3%20%3D%20int%28input%28'Enter%20Third%20number%20%3A%20'%29%29%0A%0A%0Adef%20largest%28num1,%20num2,%20num3%29%3A%0A%20%20%20%20if%20%28num1%20%3E%20num2%29%20and%20%28num1%20%3E%20num3%29%3A%0A%20%20%20%20%20%20%20%20largest_num%20%3D%20num1%0A%20%20%20%20elif%20%28num2%20%3E%20num1%29%20and%20%28num2%20%3E%20num3%29%3A%0A%20%20%20%20%20%20%20%20largest_num%20%3D%20num2%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20largest_num%20%3D%20num3%0A%20%20%20%20print%28%22The%20largest%20of%20the%203%20numbers%20is%20%3A%20%22,%20largest_num%29%0A%0A%0Adef%20smallest%28num1,%20num2,%20num3%29%3A%0A%20%20%20%20if%20%28num1%20%3C%20num2%29%20and%20%28num1%20%3C%20num3%29%3A%0A%20%20%20%20%20%20%20%20smallest_num%20%3D%20num1%0A%20%20%20%20elif%20%28num2%20%3C%20num1%29%20and%20%28num2%20%3C%20num3%29%3A%0A%20%20%20%20%20%20%20%20smallest_num%20%3D%20num2%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20smallest_num%20%3D%20num3%0A%20%20%20%20print%28%22The%20smallest%20of%20the%203%20numbers%20is%20%3A%20%22,%20smallest_num%29%0A%0Alargest%28number1,%20number2,%20number3%29%0Asmallest%28number1,%20number2,%20number3%29&amp;codeDivHeight=400&amp;codeDivWidth=350&amp;cumulative=false&amp;curInstr=18&amp;heapPrimitives=false&amp;origin=opt-frontend.js&amp;py=3&amp;rawInputLstJSON=%5B%2223%22,%2245%22,%2267%22%5D&amp;textReferences=false\" width=\"800\" height=\"650\" frameborder=\"0\"> <\/iframe><\/p>\n<\/div>\n<h4 class=\"post_h4\">Task :<\/h4>\n<p>To find the smallest and biggest number out of the given 3 numbers.<\/p>\n<h4 class=\"post_h4\">Approach :<\/h4>\n<ul>\n<li>Read 3 input numbers\u00a0using <span title=\"in Python 3\"><code>input()<\/code><\/span> or <span title=\"in Python 2\"><code>raw_input()<\/code><\/span>.<\/li>\n<li>Use two functions <code>largest()<\/code> and <code>smallest()<\/code> with 3 parameters as 3 numbers<\/li>\n<li><code>largest(num1, num2, \u00a0num3)<\/code>\n<ul>\n<li>check if num1 is larger than num1 and num2, if true num1 is largest, else<\/li>\n<li>check if num2 is larger than num1 and num3, if true num2 is largest,<\/li>\n<li>if both the above fail, num3 is the largest<\/li>\n<li>Print the largest number<\/li>\n<\/ul>\n<\/li>\n<li><code>smallest(num1, num2, \u00a0num3)<\/code>\n<ul>\n<li>check if num1 is smaller\u00a0than num1 and num2, if true num1 is smallest, else<\/li>\n<li>check if num2 is smaller\u00a0than num1 and num3, if true num2 is smallest,<\/li>\n<li>if both the above fail, num3 is smaller<\/li>\n<li>Print the smallest\u00a0number<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/biggest_smallest_3numbers.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<blockquote><p>Ad:<br \/>\n<span style=\"font-size: 18pt;\">The Complete Python Bootcamp From Zero to Hero in Python \u2013 <a href=\"https:\/\/bit.ly\/3Lw5EId\" target=\"_blank\" rel=\"noopener\">Enroll Now<\/a>.<\/span><br \/>\n<span style=\"font-size: 12px;\">Udemy<\/span><\/p><\/blockquote>\n<h4 class=\"post_h4\">Program :<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">number1 = int(input('Enter First number : '))\r\nnumber2 = int(input('Enter Second number : '))\r\nnumber3 = int(input('Enter Third number : '))\r\n\r\n\r\ndef largest(num1, num2, num3):\r\n    if (num1 &gt; num2) and (num1 &gt; num3):\r\n        largest_num = num1\r\n    elif (num2 &gt; num1) and (num2 &gt; num3):\r\n        largest_num = num2\r\n    else:\r\n        largest_num = num3\r\n    print(\"The largest of the 3 numbers is : \", largest_num)\r\n\r\n\r\ndef smallest(num1, num2, num3):\r\n    if (num1 &lt; num2) and (num1 &lt; num3):\r\n        smallest_num = num1\r\n    elif (num2 &lt; num1) and (num2 &lt; num3):\r\n        smallest_num = num2\r\n    else:\r\n        smallest_num = num3\r\n    print(\"The smallest of the 3 numbers is : \", smallest_num)\r\n\r\nlargest(number1, number2, number3)\r\nsmallest(number1, number2, number3)<\/pre>\n<p>&nbsp;<\/p>\n<h4 class=\"post_h4\">Output :<\/h4>\n<figure id=\"attachment_187\" class=\"wp-caption aligncenter\" style=\"width: 563px;\" aria-describedby=\"caption-attachment-187\">\n<p><figure id=\"attachment_725\" aria-describedby=\"caption-attachment-725\" style=\"width: 563px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-725 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest.png\" alt=\"Biggest and Smallest of 3 numbers\" width=\"563\" height=\"123\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest.png 563w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest.png 300w\" data-sizes=\"(max-width: 563px) 100vw, 563px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 563px; --smush-placeholder-aspect-ratio: 563\/123;\" \/><figcaption id=\"caption-attachment-725\" class=\"wp-caption-text\">Biggest and Smallest numbers<\/figcaption><\/figure><\/figure>\n<figure id=\"attachment_186\" class=\"wp-caption aligncenter\" style=\"width: 561px;\" aria-describedby=\"caption-attachment-186\">\n<p><figure id=\"attachment_726\" aria-describedby=\"caption-attachment-726\" style=\"width: 561px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-726 lazyload\" data-src=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest1.png\" alt=\"Biggest and Smallest of 3 numbers\" width=\"561\" height=\"126\" data-srcset=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest1.png 561w, https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest1.png 300w\" data-sizes=\"(max-width: 561px) 100vw, 561px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 561px; --smush-placeholder-aspect-ratio: 561\/126;\" \/><figcaption id=\"caption-attachment-726\" class=\"wp-caption-text\">Biggest and Smallest numbers<\/figcaption><\/figure><\/figure>\n<p class=\"extra_btn_para\"><span class=\"wdg\"> <a href=\"https:\/\/github.com\/avinashn\/programminginpython.com\/blob\/master\/biggest_smallest_3numbers.py\" target=\"_blank\" rel=\"noopener noreferrer\"> <i class=\"fa fa-github fa-lg\"><\/i> Program on GitHub<\/a><\/span><\/p>\n<div class=\"course_suggestion\">\n<h5>Course Suggestion<\/h5>\n<p>Want to learn Python with strong fundamentals? If yes, I strongly suggest you take the course below.<br \/>\nCourse: <a href=\"https:\/\/www.eduonix.com\/flow-controls-fundamentals-of-programming-in-python\/UHJvZHVjdC04MDgwMDA=\" target=\"_blank\" rel=\"noopener noreferrer\">Fundamentals of Programming in Python <\/a><\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello people, here we discuss a simple python program which finds the biggest and smallest number out of given three numbers. Here we use concept of functions in this program. We use two functions biggest() &hellip;<\/p>\n","protected":false},"author":1,"featured_media":228,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[23,36,25,38,24,26,37],"class_list":["post-70","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basic-programs","tag-basic","tag-biggest","tag-else","tag-functions","tag-if","tag-numbers","tag-smallest"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Program to find the Biggest and Smallest of 3 numbers<\/title>\n<meta name=\"description\" content=\"Python Program to find the Biggest and Smallest of 3 numbers - Programming In Python\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Program to find the Biggest and Smallest of 3 numbers\" \/>\n<meta property=\"og:description\" content=\"Python Program to find the Biggest and Smallest of 3 numbers - Programming In Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/\" \/>\n<meta property=\"og:site_name\" content=\"Programming In Python\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/programminginpython\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-20T04:56:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-14T14:11:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/fb_BiggestSmallest.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"AVINASH NETHALA\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@python_pip\" \/>\n<meta name=\"twitter:site\" content=\"@python_pip\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"AVINASH NETHALA\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Program to find the Biggest and Smallest of 3 numbers","description":"Python Program to find the Biggest and Smallest of 3 numbers - Programming In Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/","og_locale":"en_US","og_type":"article","og_title":"Python Program to find the Biggest and Smallest of 3 numbers","og_description":"Python Program to find the Biggest and Smallest of 3 numbers - Programming In Python","og_url":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/","og_site_name":"Programming In Python","article_publisher":"https:\/\/www.facebook.com\/programminginpython","article_published_time":"2021-07-20T04:56:56+00:00","article_modified_time":"2023-05-14T14:11:21+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/fb_BiggestSmallest.png","type":"image\/png"}],"author":"AVINASH NETHALA","twitter_card":"summary_large_image","twitter_creator":"@python_pip","twitter_site":"@python_pip","twitter_misc":{"Written by":"AVINASH NETHALA","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#article","isPartOf":{"@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/"},"author":{"name":"AVINASH NETHALA","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/9a3c14fe46d422ebf783ee61de1e788c"},"headline":"Python Program to find the Biggest and Smallest of 3 numbers","datePublished":"2021-07-20T04:56:56+00:00","dateModified":"2023-05-14T14:11:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/"},"wordCount":270,"commentCount":0,"publisher":{"@id":"https:\/\/www.programminginpython.com\/#organization"},"image":{"@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest-11.png","keywords":["basic","biggest","else","functions","if","numbers","smallest"],"articleSection":["Basic Programs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/","url":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/","name":"Python Program to find the Biggest and Smallest of 3 numbers","isPartOf":{"@id":"https:\/\/www.programminginpython.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#primaryimage"},"image":{"@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#primaryimage"},"thumbnailUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest-11.png","datePublished":"2021-07-20T04:56:56+00:00","dateModified":"2023-05-14T14:11:21+00:00","description":"Python Program to find the Biggest and Smallest of 3 numbers - Programming In Python","breadcrumb":{"@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#primaryimage","url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest-11.png","contentUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest-11.png","width":1920,"height":400,"caption":"Python Program to find the Biggest and Smallest of 3 numbers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.programminginpython.com\/biggest-smallest-3-numbers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.programminginpython.com\/"},{"@type":"ListItem","position":2,"name":"Python Program to find the Biggest and Smallest of 3 numbers"}]},{"@type":"WebSite","@id":"https:\/\/www.programminginpython.com\/#website","url":"https:\/\/www.programminginpython.com\/","name":"Programming In Python","description":"All About Python","publisher":{"@id":"https:\/\/www.programminginpython.com\/#organization"},"alternateName":"pip","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.programminginpython.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.programminginpython.com\/#organization","name":"Programming In Python","alternateName":"PIP","url":"https:\/\/www.programminginpython.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/04\/pip_logo_500_500.png","contentUrl":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/04\/pip_logo_500_500.png","width":500,"height":500,"caption":"Programming In Python"},"image":{"@id":"https:\/\/www.programminginpython.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/programminginpython","https:\/\/x.com\/python_pip","https:\/\/www.youtube.com\/programminginpython","https:\/\/github.com\/avinashn\/programminginpython.com"]},{"@type":"Person","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/9a3c14fe46d422ebf783ee61de1e788c","name":"AVINASH NETHALA","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.programminginpython.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed52e7670d7db94820c7430d324103ccdecb16d86611d5b29064aa9ce25a958b?s=96&d=mm&r=g","caption":"AVINASH NETHALA"},"sameAs":["https:\/\/www.programminginpython.com\/"],"url":"https:\/\/www.programminginpython.com\/author\/avinash\/"}]}},"jetpack_featured_media_url":"https:\/\/www.programminginpython.com\/wp-content\/uploads\/2023\/03\/BiggestSmallest-11.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":4,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":728,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/posts\/70\/revisions\/728"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/media\/228"}],"wp:attachment":[{"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.programminginpython.com\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}