Lesson 23 of 34

Default ಮತ್ತು Keyword Arguments

8 min 30 XP

Parameter ಗೆ default value ಕೊಡಿ. Caller ಅದನ್ನು ಬಿಟ್ಟರೆ default ಬಳಕೆಯಾಗುತ್ತದೆ.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Keyword arguments: values ಅನ್ನು ಹೆಸರಿನಿಂದ ಕೊಡಿ, ಆಗ ಕ್ರಮ ಮುಖ್ಯವಲ್ಲ. ಕೋಡ್ ಓದಲೂ ಸುಲಭ.

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Default ಇರುವ parameters, default ಇಲ್ಲದವುಗಳ ನಂತರ ಬರಬೇಕು: def f(a, b=2) ಸರಿ, def f(a=1, b) error.

Challenge

+30 XP

ಶೇಕಡಾ ರಿಯಾಯಿತಿಯ ನಂತರದ ಅಂತಿಮ ಬೆಲೆ return ಮಾಡುವ price(amount, discount=10) ಬರೆಯಿರಿ: amount - amount * discount // 100 ಉದಾಹರಣೆ: price(1000) → 900, price(1000, 20) → 800

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.