*args
*args is needed when we want to pass an unknown number of unnamed arguments. If we put * before the name of the variable, this name will take not one argument, but several. Arguments are passed as a tuple and are available inside the function under the same name as the parameter name, only without *. Let's look at the example.
123456def grocery_cart(*prices_of_all_fruits): total_price = 0 for i in prices_of_all_fruits: total_price = total_price + i print(total_price) grocery_cart(10, 7, 12, 13)
It's time to practice.
Swipe to start coding
You have to implement a function, named multiply_elements
, that will take in an unknown number of arguments and multiply all of them together. Run created a function for this set of numbers:
- (3, 6, 1, 2)
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 5.56Awesome!
Completion rate improved to 5.56
*args
*args is needed when we want to pass an unknown number of unnamed arguments. If we put * before the name of the variable, this name will take not one argument, but several. Arguments are passed as a tuple and are available inside the function under the same name as the parameter name, only without *. Let's look at the example.
123456def grocery_cart(*prices_of_all_fruits): total_price = 0 for i in prices_of_all_fruits: total_price = total_price + i print(total_price) grocery_cart(10, 7, 12, 13)
It's time to practice.
Swipe to start coding
You have to implement a function, named multiply_elements
, that will take in an unknown number of arguments and multiply all of them together. Run created a function for this set of numbers:
- (3, 6, 1, 2)
Рішення
Дякуємо за ваш відгук!
single
Awesome!
Completion rate improved to 5.56
*args
Свайпніть щоб показати меню
*args is needed when we want to pass an unknown number of unnamed arguments. If we put * before the name of the variable, this name will take not one argument, but several. Arguments are passed as a tuple and are available inside the function under the same name as the parameter name, only without *. Let's look at the example.
123456def grocery_cart(*prices_of_all_fruits): total_price = 0 for i in prices_of_all_fruits: total_price = total_price + i print(total_price) grocery_cart(10, 7, 12, 13)
It's time to practice.
Swipe to start coding
You have to implement a function, named multiply_elements
, that will take in an unknown number of arguments and multiply all of them together. Run created a function for this set of numbers:
- (3, 6, 1, 2)
Рішення
Дякуємо за ваш відгук!