Most voted "function" questions
The function (also called procedure, method, subprogram, or routine) is a portion of code intended to perform a single, specific task.
Learn more…1,309 questions
Sort by count of
-
-2
votes1
answer43
viewsHow to make a Function, replace the value of a variable in JS?
Hello! I am developing a little game in Java Script, but I am with a difficulty in the moment that the player buys a coins bonus, it will replace a value in another function, for when it is…
-
-2
votes1
answer255
viewsCalculation of the sum of the elements of a matrix
I have to develop a function in the C language to sum the elements of a square matrix of order n since i < j. I tried to test the function I did, but it gives error in line 15, which says…
-
-2
votes1
answer35
viewsWhy doesn’t the console return anything?
Hello, I’m creating a pro Chrome extension to activate some functions via checkbox. As an example for testing, I put that if the result was true, I would have to show checked in the console.log, the…
-
-2
votes1
answer48
viewsHow to call menu inside another file
I want to call a menu file done in html, inside another html file to reuse the code without having to type everything again for each module of the menu. Do I have to use PHP to do this? Follow the…
-
-2
votes1
answer95
viewsFunction that copies chained list in another chained list (excluding repeated elements) does not work
/* I need to create a function that copies a chained list passed as a parameter to another chained list (except repeated elements, if any). This is my current code #include <stdio.h> #include…
-
-2
votes1
answer105
viewsHow to create a Constructor when there is if/Else and external variables?
I have several variables like this, that call an HTML element always with the same name: var $inputFromA = $(".inputFromA"); It’s at least 10: inputFromA, inputFromB, inputFromC… All these variables…
-
-2
votes1
answer46
viewsRecursive call that returns the beginning and end of a vector
Good afternoon! I’m very lost in this matter of a college job because I didn’t understand right recursion. Could someone help me? I need it here: A function that returns the index in which the…
-
-2
votes1
answer45
viewsHow to return the result of a function to a python file
Could you help me? wanted to return the result of this function in a file for after that generate it send it to another application. I have tried several ways, but even opens the file, but when I…
-
-2
votes1
answer55
viewsBecause the variables are declared empty and then receive some value?
I was watching 1 video of a calculator project in javascript, and I saw that prof first declared a global variable with no value, and through a click function, passed a value to the variable instead…
-
-2
votes1
answer41
viewsHow to create optional parameters in C++?
In Python it is possible to have optional parameters in a function. It would look something like this: def soma(n1, n2 = 5): return n1 + n2 print(soma(5, 7)) If a second parameter is not passed n2…
-
-2
votes1
answer31
viewsBoolean function in C
College exercises. Guys, I decided to make a function so you don’t have to write the same code every time I want to know if the user will continue or not the program. What happens is that it seems…
-
-2
votes1
answer45
viewsCreate a C function, which searches how many times a letter appears in a string
I need to make this function count how many times a letter has been said in the string. However, the result always returns 0. #include <stdio.h> #include <string.h> void contador(char…
-
-3
votes2
answers9083
viewsVBA function to make text uppercase
Good afternoon. How to capitalize the spans of just a few cells of a form mounted on an excel sheet? Numeric and e-mail field cells should not be altered. I only found formulas and functions for…
-
-3
votes1
answer1085
viewsUse of python Return
def repita(): x = 2 while n % x != 0: x += 1 repeat() while n > 1: n = n / x #aqui se encontra o primeiro problema, já que "n" não é reconhecido fora da função x += 1 if n % x != 0:#mesmo…
-
-3
votes1
answer403
viewsCreate classes and functions in c++
One can give an example of how to create the main, the . h, and the . cpp in c++? and also connect them all. For example, having a function that receives an input value a, having another class that…
-
-3
votes5
answers9010
viewsHow do I multiply an array within a function in JS?
The question is basically this: We need a product function that takes an array of numbers and returns the product: the result of multiplying all the elements among themselves. For example,…
-
-3
votes2
answers93
viewsHelp validate results separately Javascript
Hello, I have this question to solve, I make the formula to find the highest value of the two numbers, but I’m having difficulty validating the results in each question. I took a print to show. The…
-
-3
votes1
answer2189
viewsFunction javascript
Sets the function today Magazine, which receives by parameter a string that informs the day of the week. This function should return"Today is football day!!!" if parameter is "Sunday", otherwise it…
-
-3
votes1
answer49
viewsHow does this function work?
That role was in my python test in college and I can’t understand it, more specifically the part of for. def exerc4(a,b,c,d,e,f): if(a > b): x = a + b elif (e > f): x= e + f else: x = a + b +…
-
-3
votes1
answer39
viewsHow do I interact specific values of a dataframe with a function?
Idade AT.49M AT.83M AT.2000M 0 0.00404 0.00269 0.00231 1 0.00158 0.00105 0.00091 2 0.00089 0.00059 0.00050 3 0.00072 0.00048 0.00041 4 0.00063 0.00042 0.00036 Having this dataframe run the function…
-
-3
votes1
answer68
viewsWhy does my function only return "even"?
function parimp(n){ for(var i = 0; i <= n; i++){ if(i % 2 == 0){ return "par"; }else{ return "impar"; } } } var s =…
-
-3
votes1
answer52
viewsHow do I check if a STRING has more than 3 characters?
I need to check if a string has more than 3 characters, how do I do this? I’ve tried it like this: nome = input('Digite um nome: ') a = [i for i in enumerate(nome)] print([i for i, y in a]) if a…
-
-3
votes1
answer71
viewsHow to insert data into the C++ string using the Geany IDE?
I’m studying String types in C. The most common was gets() however it was discontinued because of "buffer overflow". I would like to know what the equivalent function in IDE Geany to gets(). I’ve…
-
-3
votes1
answer37
viewsWhen I run on html the classification always shows Undefined, but when I run on the console it brings the answer of the _class variable can anyone help me?
<script type="text/javascript"> //função que calculao IMC do paciente. function CalcImc(peso,altura){ var imc = p/(a*a); return imc; } //Entrada de dados e…
-
-3
votes1
answer43
viewsI need to delete a folder
Hello, using visual studio, I would like to pay the following folder : C: Users leoxs Appdata Local Fivem Fivem.app cache browser Only this program will be used by other people, and they also need…
functionasked 3 years, 7 months ago Leonardo Santos 1 -
-3
votes1
answer35
viewsIncluding more Audios in a Function
o Daniel, last week suggested an audio Function, which met perfectly what I wanted. It turns out I need to insert more audios. Dai includes a #audio3 and I made the changes in Function. The result…
-
-3
votes3
answers2043
viewsI can’t solve a javascript exercise
I’m doing an exercise and I can’t solve it: The instructions are: Write the eNumerDaSorte function which, receiving a number, tells you if it is a lucky number. Remember that the number must obey…
-
-3
votes2
answers136
viewsWin function in Tic-tac-toe - Python
Hello! Facing the construction of an old game in Python, I’m doing a victory function, which will alert which of the players won the match. Below is the game algorithm under construction: def…
-
-3
votes2
answers59
viewsCan you take out the word "null" and just type on the screen "word not found" ? (using match)
That’s what I tried to do, but keeps showing up: class 46 of the javascript course null Word not found <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8">…
-
-3
votes1
answer1154
viewsProgramming a movie function - Characters
Program a movie function that receives three arrays with the names of characters, movies and year of debut in the cinema. The role should also receive an id value chosen by the user with a range of…
-
-3
votes2
answers560
viewsJavascript - Splitting into an array
I’m trying to solve an exercise, and I’m having a hard time finding out where I’m going wrong, some hint? Exercise : Program a function buscarDivisivelPor which receives two parameters, one array of…
-
-3
votes2
answers103
viewsCALCULATION USING FUNCTION WITHIN FUNCTION - JAVASCRIPT
Good afternoon, I have a problem where I can’t get the final result. The program is as follows: the user will enter the values, the operation you want (sum or subtraction), and the program will…
-
-3
votes2
answers47
viewsHow do I make an delete button disappear after it appears when it is called in a click-like addeventlistener?
I would like the "remove time" button on the page not to appear again! The page comes with an already time field The remove time button does not appear on the rendered page When the user clicks on…
-
-3
votes1
answer75
viewsWhen executing the code below, a "Syntax: invalid syntax" Syntax error appears. I cannot identify the error
from math import pi, sin, cos from math import sqrt, acos, log, exp def d_rsc (Z, p, Td, Rsea, Rstab): m = 35 * sqrt ((1224 * ((cos (Z))**2) + 1) TRTg = 1.021…
-
-3
votes1
answer33
viewsWhen I run the error appears: "Car() takes in Arguments". Can anyone help me? I don’t know what I did wrong
class Car(): """Uma tentativa simples de representar um carro.""" def _init_(self, make, model, year): """Inicializa os atributos…
-
-3
votes1
answer1234
viewsCreation of two dictionaries from a dictionary with one criterion
Read and store in a dictionary the name, age and phone number of your contacts, the key being the name. When typing an empty string for the name, the program stops reading and closes. Display the…
-
-3
votes1
answer107
viewsI’m doing a C program, which consists of implementing the Lagrange interpolation method
I’m doing a C program, which consists of implementing the Lagrange interpolation method. Where the user enters the table data (values of x and fx, and I have to return the value of lx and px, only…
-
-3
votes1
answer136
viewsFunction within a Python dictionary
I am trying to perform an exercise where when creating a log file dictionary whose key is returned a random number between 100 and 9999 as enrollment as follows from datetime import date, time,…
-
-3
votes1
answer44
viewsI’m having a problem with my code I can’t bring the data from one function to another!
I’m having a problem with my code I can’t bring the data from one function to another!! in the case of Function sum I cannot print it in function print. Can someone help me 1 - Insert into a vector…
-
-3
votes1
answer298
viewsPYTHON: Nameerror: name is not defined
What’s wrong with this code so I can’t call the function pontosNaBorda? def pontosNaBorda(v0, v1, v2): # v0, v1, v2 são coordenadas dos vértices de um triângulo return v0 def main(): alienigenas =…
-
-3
votes2
answers86
viewsHow can I simplify these two functions?
This code sums the columns and rows of a matrix separately. I created these two functions to do this and I need to simplify my code by transforming them into one. Note that the only thing that…
-
-4
votes1
answer172
viewsCreate functions in Python
I want to create a function that receives a vector of 10 records, in which each has name, state (SP or RJ) and age. And then a return function of how many people are from the same state. How could…
-
-4
votes1
answer26
viewsDoes anyone know of a function that passes the array positions?
For example, suppose I have the array [1,2,3], change to [2,3,1] and then to [3,1,2]. I’m looking for a function that together the for, can pass the array positions. Ex: for($i = 0; $i<10; $i++){…
-
-4
votes1
answer59
viewsFunction with three parameters in Javascript. Error returning "true" or "false". What to do?
I need a code that signals TRUE when the age is >= 21 years and the height >= 180 cm. The code I made is not working and I don’t know which error shows. =/ function maiorAlto(nome , idade ,…
-
-4
votes1
answer80
viewsWhat’s wrong with this excerpt?? file reading
What’s wrong with this excerpt?? I need to open a file to read and store in a struct, but if I put the condition in while feof!= 0, when I run it does not work. (this is a function that is being…
-
-4
votes2
answers54
viewsCan someone help me subtract one list from another?
I know it’s simple but I’m beating myself here to do this, I’d like to do a list subtraction in the following way lista_inicio = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "J", "Q", "K", "A"]…
-
-4
votes1
answer56
viewsProblem with exponent operator in function
destaquei o problema e descrevi na equação: M = 1000/(10 - Vinc(10)**2/299792458**2)**(1/2) //////////////////////////////////////////////////////////////////////////////// import matplotlib.pyplot…
-
-4
votes2
answers57
viewshow to last values of a variable in several different functions, in javascript,
function CalcularSoma(valor1, valor2, soma) { var valor1 = document.getElementById("formValor1").value; var valor2 = document.getElementById("formValor2").value; var soma; soma =…
-
-4
votes2
answers68
viewsJavascript function using For
I have an array with the height of several students and need to sort in groups by height. I do a for to scan the array and inside the for a conditional if to know if the student enters that group,…
-
-4
votes1
answer177
viewsIs there any way to simplify my structure? if yes how
I was able to solve this question more I wanted to know if I can simplify it because I am in the middle of learning and I look for different ways to do the same thing to be able to fix it well in…