Posts by Augusto Vasques • 15,321 points
571 posts
-
2
votes1
answer74
viewsA: How can I make the print text present more slowly?(python)
Use the print to print character by character and Sleep to create a pause between each character. In that case to print the argument is passed '' for the parameter end meaning that at the end of the…
pythonanswered Augusto Vasques 15,321 -
2
votes1
answer883
viewsA: I wonder how I get the result of a command in python that runs in CMD and save in a variable,
If you want to get the return in the terminal of a system process call use the module subprocess that allows generating new processes connect to the input, output and error Pipes, and get their…
-
0
votes3
answers1126
viewsA: How to open window to select file after pressing the Submit button?
let fileInput = document.getElementById("fileInput"); let form1 = document.getElementById("form1"); //No evento submit. form1.addEventListener('submit', (e) => { //Verifica se há algum arquivo…
-
0
votes1
answer58
viewsA: set field select as result field of a field
The only thing I can quote is that it defines a id for the element you want to reference because the attribute id specifies the unique identifier of your element and can be referenced in javascript…
-
5
votes1
answer60
viewsA: How to remove an array from occurrence found within a sub array!
Supposing $frutas is the target array of the query followed by exclusion: $frutas = [ ['maça', 1256], ['abacaxi', 1234], ['pera', 235], ['banana', 1235], ['laranja', 2135], ['limão', 2315],…
-
1
votes3
answers639
viewsA: Count to 100 with PHP
Notice: Does not specifically resolve the exercise as the questioner clarified later in the comments that the same should be done using loop while. But the simplest way to create an array containing…
-
1
votes1
answer1019
viewsA: Write a program to read 3 integer values (consider that no equal values will be read) and write them in ascending order. in JS
The question is: You really know if your algorithm works for all possible cases? When making a purely comparative ordering algorithm the first thing you should consider is the number of combinations…
javascriptanswered Augusto Vasques 15,321 -
4
votes2
answers88
viewsA: I cannot invoke a Setter or getter in Javascript
There’s a key missing { to complete the class declaration syntax and there was a mistake in its interpretation of the Setter. Setter binds an object property to a function to be called when there is…
-
2
votes3
answers348
viewsA: Arithmetic operations where some Dataframe data is not int in Python (pandas)
One solution would be to generate two Series one for prod_1 and another to prod_2 and coercively convert them to a numerical format by the method pandas.to_numeric() as a parameter errors adjusted…
-
1
votes1
answer72
viewsA: Error in calculating a PA with Haskell
The formula of General Term of PA or nth term is given by: where: a1 is the first term of PA. r is the reason for PA. n is the n-th term index of PA.. Using the color formula: termoPA :: Int ->…
-
1
votes3
answers745
viewsA: Return the positions of the largest number in a matrix
I noticed that you’re trying to agglutinate all the tasks into one thing. It would be better to divide your problem into smaller and simpler steps where in each of these steps you do just the…
-
1
votes2
answers81
viewsA: Align data tbody with theady
There are two reasons for your problem. First reason is that for each <td> created you are losing your reference. When does: var username = document.createElement('td').innerHtml =…
-
1
votes2
answers53
viewsA: cannot with Number,sent the text on the screen
I tweaked the HTML layout just to make the problem view easier. The main problem I saw was on this line: res = document.getElementById('res').value = (peso / (altura ** 2)).toFixed(2) Its intention…
-
2
votes2
answers43
viewsA: Count of boolean values
Despite NodeList not to be a Array, it is possible to iterate for NodeList using the method forEach(). //Instala o evento click para o botão cujo o id="btn".…
javascriptanswered Augusto Vasques 15,321 -
2
votes2
answers77
viewsA: How to Make an Onclick on all Page Images?
Apparently you want to install a standard event for all images on a page. To get a list containing all page images use the method querySelectorAll() of document that will return a list of elements…
-
7
votes1
answer115
viewsA: Access variable of a Function in another Function
You can make your request form asynchronous. When an asynchronous function is called, it returns a Promise. An asynchronous function is different from a synchronous function because an asynchronous…
-
3
votes1
answer402
viewsA: Python - does not allow assigning value to the variable in if conditional, why?
In Python the external variables referenced within a function are read-only global. If a variable that is global has a value assigned anywhere in the body of the function, it will be automatically…
-
1
votes2
answers56
viewsA: How to decrease decimal numbers
Inside last of the string embedded expression(result): item4.text = ${n} / ${c} = ${n/c} Enclose () around n/c and at that value evoke the method toFixed(): item4.text = ${n} / ${c} =…
-
1
votes1
answer81
viewsA: Ocaml vs Python - Function return value
Answering your question "because the values are different in the two outputs?". That function pow() that defined in Ocaml works well with small numbers: # pow(2,5) ;; - : int = 32 However in the…
-
2
votes1
answer510
viewsA: $arr = array (1,2,3,4,5,6,7,8,9,10); how do I add only even numbers within the php array?
Use the function array_reduce which reduces an array to a single value through an iterative process via callback function. <?php $arr = array (1,2,3,4,5,6,7,8,9,10); //Para cada elemento array…
phpanswered Augusto Vasques 15,321 -
2
votes2
answers742
viewsA: Python draw on the screen
Example of how to draw directly on the desktop using the Win32 API calls Movetoex() and Linet() import win32api import win32gui #Pega o contexto gráfico para o Desktop dc = win32gui.GetDC(0)…
-
1
votes2
answers53
viewsA: Add empty items at the end of array
Fill an array with a given value through the function array_fill() and combine two or more arrays by function array_merge() <?php $array1 = []; //Define um elemento vazio para posterior…
-
2
votes2
answers78
viewsA: Problem printing next 10 numbers in sequence
The operated + when it is applied to objects Number he adds them up. When the operator + is applied between Strings and Numbers he converts the Numbers in Strings and concatenates the sentence. Only…
javascriptanswered Augusto Vasques 15,321 -
1
votes2
answers152
viewsA: How do I store these values in the Torage locale?
Use the localStorage no mystery, it becomes available through the property Window.localStorage referencing an object of the type Storage that provides some methods and properties among them I…
-
1
votes7
answers1969
viewsA: How to remove repeated numbers from a python list
Reading the comments understood what is happening, when typing the list you use the literal python list syntax itself to insert it as input and the answers use a list syntax whose items are…
-
1
votes5
answers427
viewsA: How to run faster a code that calculates the number of factorial digits of a number?
You can compute the factorial of a number using the Ramanujan Gamma function which is similar to Gamma de Stirling, but it is more precise: Gamma function or Γ is the extension of the factorial…
-
2
votes3
answers391
viewsA: What are literal types in Javascript?
Font and for more details: MDN-Javascript, Syntax and types Javascript literals are fixed values, not variables, which literally are inserted into your script. The literals in Javascript are:…
javascriptanswered Augusto Vasques 15,321 -
3
votes1
answer50
viewsA: Verification error (if)
In the documentation PHP: Uploading files with the POST method is written: If no file is selected in your form, PHP will return $_FILES['userfile']['size'] as 0, and $_FILES['userfile']['tmp_name']…
phpanswered Augusto Vasques 15,321 -
1
votes4
answers1516
viewsA: how it returns the indices of a python list
If the purpose of your code is to just solve an exercise or kill curiosity about a certain type of display this solution is not better suited for you, because even the code looking simple it does…
-
2
votes2
answers92
viewsA: Text appears fast
The problem is because by clicking on a list item, its anchor <a href=""> associated redirects the browser to a blank page(about:blank) right after the content of <div id="menu"> be…
-
2
votes3
answers1145
viewsA: How to remove spaces from a string in Python without also removing line breaks?
An alternative is to generate a list from breaking the sentence in spaces(\x20) using str split.(), of the generated list filter with the bulti-in function filter() the empty strings and merge the…
-
1
votes1
answer47
viewsA: minimizar Notepad.exe external program
Use the method Process.GetProcessesByName() to obtain an array of the active processes in the system that share the same process name. Use the function ShowWindow() windows API with the parameters…
c#answered Augusto Vasques 15,321 -
2
votes2
answers1820
viewsA: How to change the color of a row in the HTML table in Javascript
One possibility is to use querySelectAll() in the document to select all rows of your table in an array, then remove the title with Array.prototype.shift() and the remaining lines for each cell by…
javascriptanswered Augusto Vasques 15,321 -
2
votes2
answers399
viewsA: Extracting words from a long text and creating statistics on them. What’s wrong?
To remove punctuation characters from a python text just one line: from string import punctuation texto = '''It is a truth universally acknowledged, that a single man in possession of a good…
-
2
votes1
answer730
viewsA: Read a JSON file and print the data in tabular format
As the data in your JSON are semi-structured, or format is not compatible with the formats returned by the method DataFrame.to_json(), what is indicated is to create the DataFrame with the function…
-
3
votes2
answers114
viewsA: convert one-dimensional array to associative multidimensional
Use the function array_chunk() to divide an array into smaller arrays whose length is a given number and function array_combine() to combine two arrays where one originates the keys and the other…
phpanswered Augusto Vasques 15,321 -
0
votes5
answers3780
viewsA: I want to know how many rows and columns an array has in Python?
Matrix is a special case of two-dimensional list in which each data line has the same number of elements or is a list of lists of equal length. Aware of this and how it was commented to get the…
-
1
votes1
answer118
viewsA: Given any number, elaborate a function that performs the sum of its digits using recursive python
Numbers are organized into classes and orders. To recursively sum the digits of a number one must find out which is the first class unit, to sum in totalizer and remove its digit from the number. To…
pythonanswered Augusto Vasques 15,321 -
3
votes1
answer259
viewsA: How to link to SVG objects?
Use element SVG <a> to create a hyperlink to other web pages, files, locations on the same page, email addresses, or any other URL. Is similar to the element HTML <a>. <span>Abra o…
-
3
votes1
answer173
viewsA: How to get the span number by an ID
In vanilla javascript you can use the property innerText of the element <span>. let span = document.getElementById("precoVinho01"); console.log(span.innerText.replace(/\s/g, '')) <span…
-
4
votes2
answers1775
viewsA: How to remove all elements from a javascript div?
To remove the descendants of an element at once set the value of the property innerText of this element as an empty string. The estate innerText returns the text content of the "as rendered" element…
-
2
votes2
answers163
viewsA: Txt generation, does not work PHP_EOL function
If the goal is to send a line break to HTML use the tag <br> <span>Quebra de linha<br>dentro dum<br>texto</span> If your goal sends a break to the console use the…
-
1
votes3
answers1379
viewsA: How to traverse an element by one in a JS array
If you need to test an array to see if any of its elements satisfy a condition use the method Array.prototype.some(). The method some() accepts a callback function and evokes it once for each…
-
1
votes1
answer218
viewsA: Error passing numpy.core. _exceptions.Ufunctypeerror: ufunc 'subtract' Did not contain a loop Signature matching types (dtype('<U21')
First thing we’re gonna do is replicate your mistake. import numpy as np def localize(aux1, aux2, aux3, aux4, aux5, aux6): search = np.array([(aux1,aux2,aux3,aux4,aux5,aux6)]) B1A =…
-
5
votes1
answer61
viewsA: How to copy the script by running to another folder in Python?
If you want to write the script, use the method copy() library shutil. from shutil import copy #Nesse exemplo foi criada previamente uma pasta chamada "nova_pasta" print("#" * 30) print("Esse script…
-
4
votes3
answers289
viewsA: How to print a Python operation by adding zero to the left?
Format the expression into a fstring: a = int(input('Número: ')) b = int(input('Número: ')) c = a / b #define a largura mínima em 2 caracteres, preenchendo com 0 a direita #remove ponto decimal se a…
pythonanswered Augusto Vasques 15,321 -
2
votes3
answers201
viewsA: Which destructive and non-destructive way to get the last element of an array?
U m a f o r m ad e s t u t i v a̶ ̶d̶e̶ ̶o̶b̶t̶e̶r̶ ̶o̶ ̶u̶l̶t̶i̶m̶o̶ ̶e̶l̶e̶m̶e̶n̶t̶o̶ ̶d̶e̶ ̶u̶m̶ ̶a̶r̶r̶a̶y̶ ̶é̶ ̶u̶t̶i̶l̶i̶z̶a̶n̶d̶o̶ ̶a̶ ̶f̶u̶n̶ç̶ã̶o̶ ̶̶a̶r̶r̶a̶y̶_̶p̶o̶p̶(̶)̶̶ ̶q̶u̶e̶…
-
1
votes2
answers108
viewsA: Doubt Python with Firebird database query
That one Decimal it’s not like Decimal firebird that’s guy Decimal python The decimal module is designed to support exact unrounded decimal arithmetic (fixed-point arithmetic) and floating-point…
-
2
votes2
answers187
viewsA: Doubt about Python’s rstrip function
Translation of Python Documentation 3.8.2 Embedded Types - Python Methods String str.rstrip([ caracteres ]) Returns a copy of the string with the final characters removed. The argument caracteres is…
pythonanswered Augusto Vasques 15,321 -
2
votes1
answer346
viewsA: How to pick up the scrollbar position with Javascript?
The algorithm is simple in the event window.scroll it makes a set of checks to know about which element the <navbar> is: checks whether <navbar> this on #sec-1 if changes the color of…
javascriptanswered Augusto Vasques 15,321