функции

Help with the function in Python

Hello everyone I'm trying to write a function that would: If the number is a multiple of 7, then the number is a multiple of ... ish the number originally entered from the nearest one...in another way, I can't implement =\ Thank you very much in advance!

C++ passing a lambda return value to a function

There is a function that simply outputs numbers from a vector. void test(std::vector<int> vec) { for(int item: vec ... ‘main()::’ to ‘std::vector I understand that as an argument the lambda itself is passed, but how to pass what it returns?

How to pass a list to a Python function argument

Hello, there is a code: num = [33,34,35,36,50] num_my = [33,36,50] num_res = [] '''Цикл проверяет повторяеться ли цифра 'nu ... append(number) return num_res num_1 = (result([54,24,1,2,3])) num_2 = (result([34,1,3])) print(num_1) print(num_2)

Why do I need constant function parameters?

Why do we need constant function parameters? We need a real use case. That is, when it is worth writing, for example, so voi ... bout why you can not overload, I have a question "why are you needed". I didn't see the answer to my question in the answers.

Combine two functions into one

There are two functions that are called when you click on the buttons, these functions work as they should. You need to make ... t have en - it no longer works here. How can these two functions be made one and the same? hang on the input{[1] event]}

Coordinate-based descent method in Python

There is a function def f(x, y): return (5 * (1 - x)) / (7.88 * (1 - y)) For the one-dimensional optimization problem, I u ... n value is minimal. x, y from the segment [0.0001, 0.9999] Can you give an example of how this is implemented in a human way?

Small delay between functions | Python

I'm trying to prescribe the functionality of an ordinary smartphone, including itself, using Tkinter. First of all, I decided ... _sprite = self.screen.create_image(98,165, image=theme) self.screen.image = theme IPhone = Smartphone() root.mainloop()

How do I remove all spaces from a string in Python?

I googled the strip() function, but it only removes the first and last spaces, and I need everything. For example, if a = ' s ... fsfs', then you need to get a = 'sddfsdfdfsfs'. Is there such a function or is it necessary to do something through the loop?

I can't fix the code for the task on stepik.org

The task sounds like this:"Write a function modify_list (l), which takes as input a list of integers, removes all odd values ... e number [6]. Comrades, could you please help me, a silly novice programmer, can you tell me how to solve this embarrassment?

Write a function that takes any number and returns the sum of the first and last number

Greetings to all. There is such a task: you need to write a function that takes any integer number as input, and returns the ... = 10; } int First = Number % 10; int Last = Number % 10 + Number; return First + Last; }

A function that checks whether a number is prime

You need to check whether the number is prime using the function. I decided like this, but it does not work completely correc ... or ( int i = 2; i * i <= num; i++ ) { if ( num % i == 0 ) { return 0; } } return 1; }

How to pass a function as a parameter in C++?

How do I declare all this and then get the return value?

Functions for updating the script after a certain period of time

Tell me, what are the functions in php to update the script after a certain period of time? In general, there is a script th ... s of the server. How to make it so that when you embed it on the site, it is updated well, for example, once every 5 seconds)

Analogous to push() for objects

Hello everyone. Today I faced such a problem. I needed to add elements to an associative array. There are no associative arra ... on JavaScript, so I made it as an object. Now I can't find an analog of the push() function. Tell me if anyone knows. Thanks.

Iterating through dataframe strings in Pandas (Python)

You need to write a function that will take each row of the dataframe, and return the column names (with a value of 1) as a l ... the same initially, but I can't think of how to swap the list of columns and df[i]. As a result, I wandered into a dead end.

Entering a python function into an array

The following code deletes not unique elements from the array. However, I want to implement it through a function and enter e ... data[:] for i in data: if data.count(i) == 1: e.remove(i) print(e) return e func(print())

Calculating the sine using the Taylor series

In this problem, we need to calculate the sine of the argument, and the use of the sin function is prohibited, that is, we us ... double x; for(int i=0; i<N; i++){ scanf("%lf\n", &x); printf("%0.15lf\n", Sin(x)); } }

Working with strings, characters. Returns an error (c++)

I enter my last name, first name, and patronymic as a single string of characters. I found out the length of the string, as w ... { Q1.erase(Q1.find('A'), 1); Q1.erase(Q1.find('O'), 1); } cout << Q1; return 0; }

Method for passing arguments to Python functions and methods

Friends, especially those who program in Python, would like to discuss the following question, which I think is more relevant ... d and what can not. I apologize for some confusion of the question, but I hope the essence of what I am asking I have stated.

What are lambda expressions?

What is it, why is it used? Examples...