Posts by Daniel Mendes • 6,211 points
247 posts
-
0
votes1
answer89
viewsA: Filter files by their extension(xml, rar, docx....)
A simple solution is to checks the file extension inside your for: //entra em um arquivo por vez pegando os dados for (i = 0; i < arquivos.length; i++) { //verifica se é um arquivo xml if…
-
1
votes1
answer64
viewsA: Function returning Undefined javascript
The function testacss receives as parameter a user and you need to look for the value 'css' on the property tecnologia of that user received, but you loop the user directly: for(let i=0; i<…
javascriptanswered Daniel Mendes 6,211 -
3
votes1
answer54
viewsA: Accordion based on a table with icons
The problem lies in the stretch of expanding and collecting the paragraph: $("#table_a").find('.imgmais').click(function(event) { let _idrowclicada = $(this).attr('class');…
-
4
votes1
answer69
viewsA: Objective of str()
The function str object to transform the received parameter into a string. If the function receives the number 1 as parameter, you will return the string '1', but she doesn’t just work with numbers.…
-
0
votes1
answer42
viewsA: How to show the sum of the values of a Column using PHP and SQL?
There are several ways to do this, one of them is to take advantage of the while and create an accumulator, which with each iteration of the while add the value of the price. <?php…
phpanswered Daniel Mendes 6,211 -
1
votes1
answer221
viewsA: COUNT function with criteria
To count records, we use the function count, as you have already put in the example query. To bring the other data you need, just inform these two fields in the query, but how the query uses a count…
-
3
votes3
answers639
viewsA: Count to 100 with PHP
Your while is correct, just then add the variable $numero in the array, for example you can use the function array_push: array_push($resultado, $numero); Or use bracketed syntax: $resultado[] =…
-
2
votes2
answers46
viewsA: Print an attribute of several classes
Creating a variable for each product can make your code very extensive, difficult to understand and maintain. The use of a list fits very well in this example, including to effect then the iteration…
-
2
votes1
answer38
viewsA: Objects in Javascript - Get
Its variable myMusic is a array, of two positions, each position contains one object. To access the position of an array, we use square brackets and between them the desired index, so would be as…
javascriptanswered Daniel Mendes 6,211 -
0
votes1
answer31
viewsA: Error request for Member 'salario' in Something not a Structure or Union
Note that when performing the calculation of totalSalario you try to access the salario of manure funcionario as if it were a array: totalSalario = cad_func.salario[0] + cad_func.salario[1]; But…
-
5
votes4
answers1041
viewsA: Doubt Exercise Python
The main problem is that you are rebooting the value of column 1 within the loop: coluna=1 Switch to reset the column to 0 and your rectangle print will already be correct: coluna = 0 The complete…
pythonanswered Daniel Mendes 6,211 -
0
votes1
answer369
viewsA: "[Error] request for Member in Something not a Structure or Union"
This error is occurring because you did not inform the type of the variable cad_func[2]. To fix this, just inform the guy, which is the struct funcionario: struct funcionario cad_func[2]; With this…
dev-c++answered Daniel Mendes 6,211 -
0
votes1
answer46
viewsA: Handling of c++ files
Use of the eof to know the end of the file: while ( !alunosE.eof() ) { That way the line reading will stay inside that while, see the full code: #include <iostream> #include <fstream>…
c++answered Daniel Mendes 6,211 -
1
votes1
answer87
viewsA: Shutdown the computer when a particular program shuts down
To turn off the computer, you can use the command shutdown passing as parameter /s, as follows: shutdown /s Since you only want to shut down after the program shuts down, you can create your script…
-
2
votes1
answer37
viewsA: Keep the last change in input saved in the browser
The localStorage can really suit you, you would need to save the current value in it, ie whenever the button is clicked and recover as soon as the page is loaded. Your JS would look more or less…
-
1
votes1
answer1666
viewsA: Python - image download via url
There are several ways to do this, see two examples, using different libraries. Using the requests: import requests with open('pato.jpg', 'wb') as imagem: resposta =…
-
2
votes2
answers26
viewsA: Nan error in object array
Replace your for in by a for of: for (let i of armazenamento) { total =+ i.valor; } The for in iterates over the properties of an object, while the for of iterates on a array, map etc... And as its…
javascriptanswered Daniel Mendes 6,211 -
9
votes2
answers1699
viewsA: How to compare each character of a Java String?
As the method chartAt returns a char which is a primitive type, you can make an equal comparison with ==, but need to put the character in between simple quotes, to identify that it is a char:…
-
2
votes2
answers43
viewsA: Division does not display numbers after the comma
As @Maniero has already said, the problem lies in the division of integers. Another possibility is to convert the value during splitting: numHarmonico += Double.valueOf(dividendo)/i; Or numHarmonico…
-
2
votes1
answer179
viewsA: take value from an elementbyid.innerhtml to calculate and place in html
To get the value of a span, you should not use the property value, but rather the innerHTML. Both to obtain the value and to exchange the same. function trocarValorSpan() { var parcela =…
-
1
votes2
answers398
viewsA: Play again, not "clean" board - Old Python game
One option is to create a function that returns the empty board. You have the following snippet that initializes the empty board: posicao = { 'pos1': 1, 'pos2': 2, 'pos3': 3, 'pos4': 4, 'pos5': 5,…
pythonanswered Daniel Mendes 6,211 -
1
votes1
answer678
viewsA: Add Items to a Flatlist
The button may even be adding your item to the list, but the React does not know that you need to render the data again FlatList. For you to work with this kind of change in the status of the…
-
1
votes1
answer230
viewsA: Search in two-dimensional array
To perform searches on a two-dimensional array, you also use the function aScan, but as a second parameter you do not put exactly the value you want to find, but rather a code block containing an…
-
0
votes1
answer423
viewsA: Error: not all Arguments converted During string formatting
This error occurs because you are trying to use the operator % in a string: if v % 2 == 0: When using the function input to take the data, this function returns a string, even the user typing a…
-
1
votes2
answers1060
viewsA: Make a program that inverts an integer number with two digits
Following your code, just convert the contents of the variable d to integer using the function int, this conversion will already remove the zero left, to effect a line break, we can use the "\n":…
-
2
votes2
answers112
viewsA: function does not execute regex equal words
There is a problem, the replace is only performing a substitution the way it is being used, when finding the first occurrence it replaces and has ended... Since you have two identical words, it…
-
0
votes2
answers64
viewsA: Repeat odd numbers with do while
The verification impar0a200%2 != 0 is correct, just then use this condition in a if and being true, display the number. if (impar0a200 % 2 != 0) { cout << impar0a200 << endl; } This…
c++answered Daniel Mendes 6,211 -
1
votes1
answer383
viewsA: create routes with React-router-dom
The error is occurring because your Routes.js has an incorrect syntax in the tag <Route>. Your route is being defined as follows: <Route path= "/" exact componemt= {Logon} /> <Route…
-
0
votes1
answer53
viewsA: getter-Setter error #python
Turns out you’ve defined two methods set_nome, one is changing the value of the property __nome and the other of the estate __sobrenome: def set_nome(self,novo_nome): self.__nome = novo_nome def…
-
2
votes1
answer29
viewsA: Contador Regresso
You can do this by creating a new control variable for the count, thus keeping the variable i for the animation: We change the value of h2 to 30. We create the variable count which will be the…
javascriptanswered Daniel Mendes 6,211 -
0
votes2
answers181
viewsA: Validate password confirmation field, why does confirming field not work?
To validate whether the passwords are equal, you should compare the contents of the fields and not the size of the contents. See, you made the comparison by taking the content size (length): if…
-
8
votes3
answers162
viewsA: Another alternative to not repeat this "function" three times?
Yes, it is possible and there must be countless ways to do this. One of them is very simple, is to create a function that contains the logic where you request the numbers from the user and add in…
-
1
votes3
answers54
viewsA: error in percentage?
Turns out your condition if(salario > 600.00 || salario <=1200.00) is with a logical OU... With this, any number greater than 600 will fall in this condition, never reaching the other…
canswered Daniel Mendes 6,211 -
1
votes1
answer47
viewsA: My code is having infinite loop, which is wrong
When the page is loaded, you end up calling the function: $(document).ready(function(){ And within it, you make the call of function loadd, so far smoothly. Turns out its function loadd is recursive…
-
1
votes1
answer117
viewsA: python3 Tkinter scrollbar problems to insert
Turns out you’re trying to create a scroll in a Label and this class doesn’t have the option yscrollcommand. You can use this property at Listbox, Canvas etc.. See an example of using it with the…
-
3
votes3
answers170
viewsA: Remove the brackets from the Sorted() function
There are several ways to do this. You can create a variable that receives the return of the function sorted and then access the array indexes: raizes = [10, 5] raizesParaExibir = sorted(raizes)…
pythonanswered Daniel Mendes 6,211 -
1
votes1
answer1242
viewsA: Smallest value typed in a vector
You got a lot of problems here. When you declare a variable in C and do not assign a value, it may contain a memory junk, i.e., its array numero[10] can contain dozens of values you have no idea,…
canswered Daniel Mendes 6,211 -
1
votes3
answers95
viewsA: How do I leave the primary and foreign key of a table with the NOT NULL Constraint in Postgresql?
To not allow null values, when creating the field, just inform not null, example: CREATE TABLE fornecedor ( cd_fornecedor SERIAL PRIMARY KEY, cd_endereco_fornecedor INT not null,…
-
4
votes2
answers86
viewsA: How would you solve this simple question?
You don’t need to sort the list with each data entry, you can do this only at the end, because the methods sort and reverse work with all data from the list: numeros = [] for i in range(0,3):…
-
3
votes2
answers487
viewsA: How to use the return of a function in another Python function
It’s very simple, just call the function calcular_velocidade as a function parameter calcular_aceleracao: calcular_aceleracao( calcular_velocidade(20, 2) , 2) Your example would look like this: def…
-
0
votes1
answer482
viewsA: Sqlite Database is in 'binary' format in Visual Studio Code
Vscode by default cannot open this type of file. In fact, several other extensions and even languages are not recognized by it, for that it is necessary to install extensions in the same. There are…
-
0
votes2
answers550
viewsA: SQL Server - Select last 7 days from the last record
Following your example, you can make this filter on where, using a subselect: select * from vendas where ven_data <= ( select max(ven_data) from vendas ) and ven_data >= ( select dateadd(day,…
-
2
votes1
answer321
viewsA: command prompt instantly closing
This is normal and even expected. The prompt is open while your program is running, at the end it closes. You can create forms of it not close immediately, it is quite common to use the function…
-
1
votes3
answers165
viewsA: Error with Random function
That value: <bound method Random.randint of <random.Random object at 0x0000015E1A1D4FD0>> It is not an error, it is the literal value of the function randint. Notice that you imported…
-
0
votes2
answers24
viewsA: Operation using another table field
This happens, because you used fields in the query that need to be in group by, in case the field PRODUTO table ITMVTO_ESTOQUE: WHERE U.CD_PRODUTO = IE.PRODUTO To fix this, just add the field…
-
2
votes2
answers279
viewsA: How to divide strings into equal parts
A possible solution would be to make a while in the string according to its size (length) and within the while, you go break the string with substring, taking a chunk of it and adding it to an…
-
1
votes1
answer44
viewsA: how to convert a number to real (money)?
You actually wrote down the value of n1 in HTML with the method toFixed, while should have done it with the method toLocaleString. The use of the method toLocaleString is correct, but you used it…
-
2
votes1
answer66
viewsA: Custom menu
A suggestion would be to remove the second parameter (itens) of function personalizado, because as you receive in the third parameter a tuple, you can iterate in it and discover the amount, with…
-
0
votes2
answers159
viewsA: Make Join in table that has two ID in the same column
How the data is present in SO_TABLE without formatting, a possible solution is to try to do the join of these tables using the like of SQL. If the data present in TECH_TABLE.SO_ID is contained in…
-
0
votes2
answers152
viewsA: error mysql.connector.errors.Programmingerror: Not enough Parameters for the SQL statement
The problem is in the way you are reading the csv file. In the following passage: csv_data = csv.reader('/Users/eduardoaandrad/Dropbox/Desenv/Script/csv/carga_teste.csv',delimiter=';') The reported…
pythonanswered Daniel Mendes 6,211