MathsGee Answers is Zero-Rated (You do not need data to access) on: Telkom | Dimension Data | Rain | MWEB
First time here? Checkout the FAQs!
x
MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

0 like 0 dislike
25 views
What does the **kwargs do in Python?
in Data Science & Statistics by Bronze Status (8,758 points) | 25 views

1 Answer

0 like 0 dislike
Best answer

We can also use the **kwargs syntax in a Python function declaration. It let us pass N (variable) number of arguments which can be named or keyworded.

Example of using the **kwargs:

# Python code to demonstrate 
# **kwargs for dynamic + named arguments 
def fn(**kwargs):  
    for emp, age in kwargs.items(): 
        print ("%s's age is %s." %(emp, age)) 
    
fn(John=25, Kalley=22, Tom=32)

The output:

John's age is 25.
Kalley's age is 22.
Tom's age is 32.

 

by Bronze Status (8,758 points)

Related questions

0 like 0 dislike
1 answer
asked Jun 26, 2020 in Data Science & Statistics by Teddy Bronze Status (8,758 points) | 42 views
0 like 0 dislike
1 answer
asked Jun 26, 2020 in Data Science & Statistics by Teddy Bronze Status (8,758 points) | 36 views
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jun 26, 2020 in Data Science & Statistics by Teddy Bronze Status (8,758 points) | 21 views
0 like 0 dislike
0 answers
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

MathsGee provides answers to subject-specific educational questions for improved outcomes.



On MathsGee Answers, you can:


1. Ask questions
2. Answer questions
3. Comment on Answers
4. Vote on Questions and Answers
5. Donate to your favourite users

MathsGee Tools

Math Worksheet Generator

Math Algebra Solver

Trigonometry Simulations

Vectors Simulations

Matrix Arithmetic Simulations

Matrix Transformations Simulations

Quadratic Equations Simulations

Probability & Statistics Simulations

PHET Simulations

Visual Statistics

Other Tools

MathsGee ZOOM | eBook

16,915 questions
12,344 answers
122 comments
2,436 users