Please help me with the Python example question!

Asked 2 years ago, Updated 2 years ago, 14 views

Create a function (make_car) in your dictionary that stores car information and save it to carfunc.py! This function must always receive the manufacturer name and model name. And you need to receive a random number of keyword parameters.

When you import the above function module to call a function, write a program that puts in the required information and colors, adds two key-value pairs, such as options and functions, and prints the results.

Call Example

car = carfunc.make_car('modern', 'granger', color='blue', blackbox='equipped')

It's an example question, but I don't know how to code it Help!

python

2022-09-20 20:07

1 Answers

#!/usr/bin/env python3
## ## ~/carfunc.py
def make_car(maker, model, **kwargs):
    print(kwargs.get("color"))
    pass

make_car ("Hyundai Kia", "Grenzer", color="red")

I wrote only the parts that could be a little difficult.

I think the kwargs part was difficult.

If you look at the code above, I think you can get the hang of it right away.


2022-09-20 20:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.