{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihjowwurrakiw2rvzuzuenl5b3yvcy2b3xug6uheqb4id4jm4surm",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpne2gk6sb72"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreiggnbytxe6evcodgheg7dsdrswy2syx7cnhj4vvl2rwfqkf3wdppu"
},
"mimeType": "image/webp",
"size": 27960
},
"path": "/punitha2206/functions-in-python-b22",
"publishedAt": "2026-07-02T05:51:11.000Z",
"site": "https://dev.to",
"tags": [
"function"
],
"textContent": "What is a Function?\n\n * A function is a block of reusable code that performs a specific task.\n\n\n\nWhy Use Function?\n\n * Reuse code multiple times\n\n * Improve code readability\n\n * Reduce code duplication\n\n * Make programs easier to maintain\n\n\n\n\n**Syntax:**\n\n\n\n def function_name():\n <statement>\n\n\n**Example:**\n\n\n\n def greet():\n print(\"Hello, Python!\")\n\n greet()\n\n\n**Output:**\n\n\n\n Hello, Python!\n\n\n**Three types of Functions:**\n\n * Function without Parameters\n\n * Function with Parameters\n\n * Function with return values\n\n\n\n\n**Function without Parameters:**\n\nA function that does not accept any input values is called a function without parameters.\n\n**Example:**\n\n\n\n def greet():\n print(\"Hello, Python!\")\n\n greet()\n\n\n**Output:**\n\n\n\n Hello, Python!\n\n\n**Function with Parameters:**\n\nA function that accepts input values is called a function with parameters.\n\n**Syntax:**\n\n\n\n def function_name(parameter):\n <statement>\n\n\n**Example:**\n\n\n\n def greet(name):\n print(\"Hello\", name)\n\n greet(\"World\")\n\n\n**Output:**\n\nHello World\n\n**Function with Return Value:**\n\nA function that returns a values using the return statement.\n\n**Example:**\n\n\n\n def add(a, b):\n return a + b\n\n result = add(10,20)\n print(result)\n\n\n**Output:**\n\n\n\n 30\n",
"title": "Functions in Python"
}