Multiple parameters वाले functions
पिछले लेक्चर में Hugo ने फंक्शन परिभाषित करते समय multiple parameters के उपयोग पर चर्चा की थी। अब आप उसी सीख को इस्तेमाल करके shout() फंक्शन में और संशोधन करेंगे। यहाँ, आप shout() को दो आर्ग्युमेंट स्वीकार करने के लिए बदलेंगे। फंक्शन shout() के कुछ हिस्से, जो आपने पहले लिखे थे, नीचे दिए गए हैं।
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Functions का परिचय
अभ्यास निर्देश
- फंक्शन हेडर को ऐसा संशोधित करें कि वह दो पैरामीटर
word1औरword2इसी क्रम में स्वीकार करे। word1औरword2में से प्रत्येक को'!!!'से जोड़कर क्रमशःshout1औरshout2को असाइन करें।shout1औरshout2को, इसी क्रम में, जोड़करnew_shoutको असाइन करें।- स्ट्रिंग्स
'congratulations'और'you'को, इसी क्रम में,shout()की कॉल में पास करें। रिटर्न वैल्यू कोyellमें असाइन करें।
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Define shout with parameters word1 and word2
def shout(____, ____):
"""Concatenate strings with three exclamation marks"""
# Concatenate word1 with '!!!': shout1
# Concatenate word2 with '!!!': shout2
# Concatenate shout1 with shout2: new_shout
# Return new_shout
return new_shout
# Pass 'congratulations' and 'you' to shout(): yell
# Print yell
print(yell)