Posts by G. Bittencourt • 501 points
15 posts
-
1
votes1
answer196
viewsQ: How to remove an object from a list chained by the value of the attribute in C++?
What is the best way to remove an element from a list by the value of its attribute, without knowing exactly its position? I realized that the method Erase remove by position, and tried to use along…
-
2
votes1
answer42
viewsA: What is the need for this variable in this loop?
The method enumerate returns an eternal object. When you do the enumerate from a list, by going through this list you access tuples with 2 elements. In its second code, the loop variable file is…
pythonanswered G. Bittencourt 501 -
6
votes4
answers292
viewsA: How to find the index of an object in a javascript list
The method Array.findIndex allows to find the index of the element that satisfies a certain condition. let list = [ {nome: "joão", idade: 15}, {nome: "pedro", idade: 17}, {nome: "felipe", idade:…
javascriptanswered G. Bittencourt 501 -
0
votes2
answers109
viewsA: Do not redirect form - nodejs
You can specify a method to be executed when submitting the form <form id="contacts" autocorrect="off" name="adicionar" onsubmit="return mySubmitFunction(event);" > And in implementing the…
-
1
votes1
answer96
viewsA: Subtract values using sqlite in Python
You can pass the variable quantidade in your query variable: consulta = "UPDATE OR IGNORE Produtos SET quantidade = quantidade - %d" %quantidade
-
1
votes3
answers333
viewsA: Return only the positive values of an array
In your code, when finding a positive balance the function is stopped and the entire array is returned, without any change. In the following code, positive values are inserted into a new array, and…
javascriptanswered G. Bittencourt 501 -
1
votes1
answer126
viewsA: Python sum recursion
Its recursive function has only one criterion, which is when le > z, when this check is not true, your function should return the final result. From what I understand of your code, h is the…
pythonanswered G. Bittencourt 501 -
3
votes1
answer87
viewsA: Consistency in Python results
np.random.seed(0) defines that the random generation of numbers will follow a predefined pattern. In doing np.random.seed(0), the next call from numpy.random.rand(n), being n the size of the vector…
-
1
votes3
answers1665
viewsA: Doubt in percentage in C
The correct calculation of the discounted value is: end = preco - ( preco * desc / 100 ); whereas desc is the amount of the discount (in percent) between 0 and 100.…
canswered G. Bittencourt 501 -
2
votes3
answers15114
viewsQ: How to change the color of only one word in a paragraph?
For example, in a paragraph: <p id="paragrafo"> Bla bla bla banana uva morango bla bla bla </p> How would I change the color of just the word "grape," for example?…
-
2
votes1
answer101
viewsQ: Segmentation Fault function that changes the values of 2 strings
The following function changes (or at least should) the content of two strings void trocar(char *a, char *b){ char *novo = (char *) malloc(sizeof(char) * 10); strcpy(novo, a); strcpy(a, b);…
-
1
votes1
answer107
viewsA: How to import packages within other subpackages in Python?
Since both(Pacote1 and Pacote2) are within the same root directory, just do, in Modulo2.py: from Pacote1 import Modulo1 to import Modulo1.py, or: from Pacote1.Modulo1 import nomeDaFuncao to import a…
-
1
votes1
answer382
viewsA: Condition with Python letter
I don’t quite understand what you want to do. You want to print only if the received character is the letter "a"? If that’s it, try: test = input("Letra: ") if(test == 'a'): print("mensagem")…
-
3
votes1
answer363
viewsA: Create a python function that returns a number that is the amount of equal values of two columns
Well, there are some syntax errors in your code. I will try to list them. 1º - To declare a variable of type string just do: nomeVariavel = "conteúdo da string" 2º - Your function is not receiving…
pythonanswered G. Bittencourt 501 -
1
votes2
answers132
viewsQ: How to analyze the input in the while condition?
I am learning C, and as the language in which I was "literate" is Python, I usually make associations to better assimilate. In Python, I can receive a direct value in the while condition. Ex.: while…