Python Functions: Write Once, Use Many Times

𝐈 𝐰𝐫𝐨𝐭𝐞 𝐭𝐡𝐞 𝐬𝐚𝐦𝐞 𝐥𝐢𝐧𝐞 𝟕 𝐭𝐢𝐦𝐞𝐬 𝐛𝐞𝐟𝐨𝐫𝐞 𝐥𝐞𝐚𝐫𝐧𝐢𝐧𝐠 𝐭𝐡𝐢𝐬 😩 A function is just a named block of code you can run anytime. def = define. then call it by name. 𝑾𝒉𝒚 𝒖𝒔𝒆 𝒕𝒉𝒆𝒎? → Write once, use many times → Easier to fix bugs (one place) → Cleaner code that humans can read 𝑲𝒆𝒚 𝒇𝒆𝒂𝒕𝒖𝒓𝒆𝒔: → 𝑷𝒂𝒓𝒂𝒎𝒆𝒕𝒆𝒓𝒔: Values you pass into a function so it can work with different data each time. → 𝙍𝙚𝙩𝙪𝙧𝙣: The value a function sends back to you after it finishes its job. → 𝘿𝙚𝙛𝙖𝙪𝙡𝙩 𝙖𝙧𝙜𝙪𝙢𝙚𝙣𝙩𝙨:Fallback values that a function uses if you don't pass anything for that parameter. → 𝘿𝙤𝙘𝙨𝙩𝙧𝙞𝙣𝙜𝙨: A short note inside a function that explains what it does (for you and others reading the code). 𝙁𝙪𝙡𝙡 𝙘𝙤𝙙𝙚 + 𝙚𝙭𝙖𝙢𝙥𝙡𝙚𝙨: 🔗 Vist my Github :https://lnkd.in/drGxebiM 𝑶𝒗𝒆𝒓 𝒕𝒐 𝒚𝒐𝒖: 👇 Type "GUILTY" if you've ever written the same loop 4 times in one script.😅 #python #AiEngineer #coding

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories