{"id":31559,"date":"2021-04-08T10:35:35","date_gmt":"2021-04-08T08:35:35","guid":{"rendered":"https:\/\/eiposgrados.com\/?p=31559"},"modified":"2021-04-12T11:26:58","modified_gmt":"2021-04-12T09:26:58","slug":"phyton-predefined-functions","status":"publish","type":"post","link":"https:\/\/eiposgrados.com\/eng\/blog-python\/funciones-predefinidas-phyton\/","title":{"rendered":"Predefined functions in Python"},"content":{"rendered":"<p>A<strong> function<\/strong> it&#039;s a <strong>code block<\/strong>, which receives zero or more arguments and performs an operation to return a value and\/or performs a specific task. The functions must have a<strong> assigned name <\/strong>to be able to \u201ccall\u201d them during the execution of the program and they are completely <strong>reusable.<\/strong><\/p>\n\n\n\n<p>Although you can create all kinds of functions, today we are going to focus on those that come <strong>by default integrated into Python.<\/strong> If you want to develop your career in<strong> Python<\/strong>, we recommend you visit our<strong><a href=\"https:\/\/eiposgrados.com\/eng\/master-in-python\/\" class=\"rank-math-link\"> master in Advanced Programming in Python for Big Data, Hacking and Machine Learning<\/a> <\/strong>and train with the best experts.<\/p>\n\n\n\n<p>To start we can use the function <strong>dir()<\/strong> to list all predefined functions. We can get help from different functions with <strong>help()<\/strong>, for example the function <strong>max():<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most notable predefined functions <\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>list()<\/strong> Create a list from an element.<\/li><li><strong>tuple()<\/strong> Create or convert to a tuple.<\/li><li><strong>type()<\/strong> Returns the type of the element passed as a parameter.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">To work with text:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>print()<\/strong> Prints on the screen the argument that we pass to it&nbsp;<\/li><li><strong>len()<\/strong> It returns the length in characters of the string that we pass as a parameter<\/li><li><strong>replace()<\/strong> Replaces a string with the one it includes as an argument.<\/li><li><strong>upper()<\/strong> Converts the string passed as an argument to uppercase<\/li><li><strong>lower()<\/strong> Converts the string passed as an argument to lowercase<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">And the most used numerical functions:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>sum()<\/strong> Sums the list of numbers passed as an argument.<\/li><li><strong>min()<\/strong> Determines the minimum value of a list of numbers passed as an argument.<\/li><li><strong>max()<\/strong> Determines the maximum value of a list of numbers passed as an argument.<\/li><li><strong>range()<\/strong> Creates an arithmetic list of numbers based on the value passed as an argument.<\/li><li><strong>str()<\/strong> Converts a numeric value to text.<\/li><\/ul>\n\n\n\n<p>There are many more predefined functions in<strong> Python<\/strong>, you can learn to use them and even create functions yourself.<\/p>","protected":false},"excerpt":{"rendered":"<p>Do you know what a function is in Python? We explain which are the best-known predefined functions in Python and what they are used for. <\/p>","protected":false},"author":51,"featured_media":31562,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[407],"tags":[],"class_list":["post-31559","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-python"],"acf":[],"_links":{"self":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/31559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/comments?post=31559"}],"version-history":[{"count":0,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/31559\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media\/31562"}],"wp:attachment":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media?parent=31559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/categories?post=31559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/tags?post=31559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}