Posts by Augusto Vasques • 15,321 points
571 posts
-
0
votes2
answers66
viewsA: How to get specific text from a txt file in C#?
The algorithm is simple: File.ReadAllLines("file.txt"): Read the text file. SkipWhile(l => l != "Nodal Moment point"): Discard all lines until you find the string "Nodal Moment point". Except(new…
-
1
votes2
answers57
viewsA: Add and remove rows in a table
Initially it has to be noted that the code presented in the question has a serious problem with the id attributes. Follows excerpt from the documentation: The global id attribute defines a unique…
-
1
votes3
answers79
viewsA: Greatest prime number
Knowing that: f(x) = 2x + 1 | x N is the function in the set of natural numbers defining the odd numbers. range(0) is an empty sequence. At the express [identificador ":="] expressão is a expression…
-
1
votes7
answers15010
viewsA: Print "n" natural odd numbers
It is also possible to solve the problem without using any iteration loop type, just unpacking the values of the sequence, generated with range(), using the operator * and passing them as arguments…
pythonanswered Augusto Vasques 15,321 -
1
votes2
answers68
viewsA: Join cells with python
The method of reading the table in html that uses is mistaken because it is verbose, complicated and conducive to errors, in addition to being subject to the specifics of a very tough and specific…
-
2
votes1
answer44
viewsA: Merge lists based on key column value
You can group a Dataframe by the data in a column with the method DataFrame.groupby() which divides the objects into groups defined by a criterion, in which case the data in the column will be…
-
4
votes1
answer70
viewsA: How to read a csv file by pandas without erasing the first number?
Archives CSV does not come with definition of the data types of your columns. So the Pandas module when reading a CSV should infer the most appropriate type of data. In your case the test column has…
-
2
votes1
answer56
viewsA: Return tag element in Beautifulsoup
If your goal is to extract the textual content from a document or textual content under a tag, you can use the method get_text() that returns all the textual content of the document or under a tag:…
-
1
votes2
answers82
viewsA: Sort two lists based on the order of the first
Has en route to functional programming using builtin functions zip() to join the two lists, sorted() to order this junction and map() to apply a sorted list separator function: x = [7, 5, 9, 4, 2,…
-
3
votes2
answers76
viewsA: Why does Lua’s "print" print print extra spaces in the arguments?
Checking the documentation of the function print(): Takes any number of arguments and prints their values in stdout, using the function tostring() to convert each argument passed in a string.…
-
4
votes2
answers114
viewsA: What is a daemon?
Etymology of the word daemon: In a document from Virginia Tech/Norfolk State University entitled The Origin of the word Daemon the explanation for the origin of the word "daemon": I write a…
nomenclatureanswered Augusto Vasques 15,321 -
4
votes4
answers150
viewsA: What regular expression to use to replace symbols in a string?
Still complementing the other answers it is also possible to get the desired output using principles of functional programming. const input = '5,5x8÷7'; const tokenMap = { ',': '.', 'x': '*', '÷':…
-
1
votes2
answers56
viewsA: Merge arrays and merge in php
To interlink array widgets $aviso with the array elements $musica, provided that: Both lists are not empty. The length of $musica is greater than the length of $aviso. Itere by array elements…
phpanswered Augusto Vasques 15,321 -
2
votes2
answers77
viewsA: In a Dataframe, modify data from one column conditioned to the value of another column
To change values in a column where it depends on values in other columns, use the method Series.mask() replacing values where given conditions are true. Example: In the column Amount, df["Amount"],…
-
1
votes1
answer95
viewsA: Remove Row and Column Indexes in the Dataframe
The function sought is the method itself DataFrame.to_string() that is already being used. Only requirement to fulfill the requested task is the adjustment of two parameters: header which determines…
-
2
votes1
answer45
viewsA: How to exchange a word between a limit created by two specific points within a string?
Edit: As we remember comments by the user hkotsubo the standard has been added \b which corresponds to an empty string attached to the beginning and end of the pattern determining a formal limit of…
python-3.xanswered Augusto Vasques 15,321 -
2
votes2
answers91
viewsA: Adding a character to a python str
Use fstring: import pyautogui from datetime import datetime data_atual = datetime.now() pyautogui.write(f'{data_atual.day:02}') fstring is a literal string prefixed with 'f' or 'F'. These strings…
pythonanswered Augusto Vasques 15,321 -
1
votes2
answers63
viewsA: Is there a possibility of knowing when a field bursts width?
To know if one element overflowed a width compare the properties Element.scrollWidth and Element.clientWidth. $(document).ready(function() { $("#entrada").on("input", function() {…
-
1
votes1
answer365
viewsA: Extract specific information from an excel cell using pandas in Python
For from a column containing birth dates on string in format dd/mm/yyyy to be separated into columns containing day, month and year of that date: Using a Dataframe of similar structure to that of…
-
4
votes3
answers102
viewsA: My variables are not being counted in the code
someone could explain to me what I could do to solve the code? Rewrite the algorithm. Within an infinite loop... Convert the input numeros, which is returned by window.prompt() as String, in an…
-
1
votes1
answer136
viewsA: Function within a Python dictionary
As for the question. No, you are not using the function correctly random.randint() and the other answers also do not make a correct use of the function. How are enrolling students in a dictionary…
-
0
votes5
answers789
viewsA: List comprehension with conditional
As colleagues have already said, the two points are missing : after for x in seq and if x == max and python does not allow certain constructs to be positioned on the same line: cont = 0 seq = [1, 2,…
-
1
votes2
answers54
viewsA: I’m creating a currency converter, and it returns a wrong value
Heed: Monetary values should not be modelled as floating point numbers due to intrinsic imprecision of the numerals described in the standard IEEE 754. The scope of this response is restricted to…
javascriptanswered Augusto Vasques 15,321 -
1
votes3
answers1627
viewsA: Nested lists in python
If you want to print individually the elements of a simple irregular sequence, a sequence formed of regular sequences, one option is to flatten this sequence to print individually the elements in…
-
0
votes3
answers91
viewsA: Make a program that receives 5 numbers and show the following output:. C++
EDIT: The index range used was corrected. In C++ arrays indexes start at 0. Use a conditional ternary expression //Se i < 4 insere uma string " + " na saída padrão, senão não faz nada. cout…
-
4
votes3
answers104
viewsA: How do I make Python not turn to the upper or lower case letters of the code?
As already stated in the comments: Use the methods str.lower() or str.upper() to get a copy of the entry in lower or upper case and make the comparison. Apply a conversion of str() the exit of a…
-
1
votes1
answer77
viewsA: Validate an integer number in Python 3
Use: try...except with using int() nestled: while True: try: num = int(input('Escolha um número: ')) break except ValueError: print("Não é um número!") print(f'{num} é um número inteiro.') Using the…
python-3.xanswered Augusto Vasques 15,321 -
3
votes1
answer172
viewsA: What is the breakpoint function for
The built-in function breakpoint() calls the Python Interactive Source Code Debugger. This debugger features: Support the definition of conditional and single-pass interruption points at source.…
-
3
votes2
answers112
viewsA: When is an Slice data copied?
As we were told comments: When you use Slice, you are making a copy of that list, the same behavior works using the copy() python. Here a simple test where a slice(Slice) of a and its reference is…
-
0
votes2
answers392
viewsA: I need to join several excel files in a single split into python folders. I did this method but wanted to create a function:
A possible refactoring using a partial function: from functools import partial import pandas as pd ufv_name = ['CB1', 'CB2', 'CB3', 'GM1', 'IM1', 'JD2', 'PIU', 'STR'] def readxlsx(ufv, d, m): return…
-
1
votes2
answers51
viewsA: When one Function terminates the other ends also multiprocessing asynchronous functions
If there is no need to end the process immediately pB is possible with the method terminate() signaling from one process to another that is finalized by passing its reference through the parameters…
-
0
votes2
answers44
viewsA: Print all if conditions
First separate the recurring code into functions. In programming language the basic idea of function is to encapsulate a code that can be invoked/called by any other part of the program, that is, a…
pythonanswered Augusto Vasques 15,321 -
2
votes1
answer86
viewsA: How could I resolve this issue using Python dictionaries?
One way to solve this problem is by using ensembles. A set object is an unordered collection of distinct hasheable objects, there is no repetition of elements. Common uses include association tests,…
pythonanswered Augusto Vasques 15,321 -
1
votes2
answers55
viewsA: Python: Run class or element inside a class
I don’t know exactly what you want to do, but there are some ideas: Initially you can remove class nesting and instantiate a property: class CrudTDados: def __init__(self, parent): self._parent =…
-
1
votes1
answer50
viewsA: interact with Select option dynamically via javascript
To record an event listening in an element use the method Element.addEventListener(), pass in the first parameter the type of event that will remain in wait and in the second a function you will…
-
1
votes6
answers3314
viewsA: Get the local time in javascript with zeros?
Make it simple use native method Date.prototype.toLocaleTimeString() passing as parameter the location, in the example I used en, and an object containing the configuration options method. As…
-
2
votes2
answers61
viewsA: Loop while not working well - Hakerrank
Can anyone tell me the problem with this code? Yes, I say the code is all wrong. For the following reasons: The approach is too complicated for a simple problem. It doesn’t even solve your initial…
python-3.xanswered Augusto Vasques 15,321 -
0
votes2
answers417
viewsA: while True inside while True
If it is a situation created as a hobby or puzzle, one can raise a exception treated: while True: try: test = input('Digite pra ir pro proximo while True: ') while True: test1 = input('Digite (S)…
-
0
votes2
answers55
viewsA: How to change background-color every time the page refreshes? - Javascript
Every time the document loads select a color randomly. const cores = ['black', 'red', 'navy']; window.addEventListener('load', function() { document.body.style.backgroundColor =…
-
1
votes2
answers77
viewsA: nextLine() problem inside the loop
Not everything on the Internet is true or real. Despite being quite widespread on the internet the use of class instances java.util.Scanner as a substitute for the use of the method…
-
1
votes3
answers90
viewsA: How to put two functions in onclick for one to be done if the other works
In modern browsers register one or more of a listeners of events with Element.addEventListener(). If multiple event listeners are attached to the same element for the same type of event, they will…
javascriptanswered Augusto Vasques 15,321 -
2
votes1
answer87
viewsA: How to show other codes within HTML?
Is there a tag that shows codes of other languages on the page? Yes, the HTML element <code> presents its stylized content to indicate that the text is a small fragment of code. To represent…
-
0
votes4
answers350
viewsA: How to add values from a dictionary with arrays by the Python key?
Still have the functional alternatives: With built-in function map(função, iterável, ...) apply a function that for each tuple in the form of (chave, valor), do the summation of value and return a…
-
5
votes1
answer70
viewsA: Input Submit value in two colors
View documentation <button>: The Button element : Content allowed: Permitted phrasing but not interactive content. Then just place a valid content inside the button and apply a style. .txt1 {…
-
2
votes3
answers128
viewsA: How to browse a JSON within another JSON in Python?
There is no unique way to iterate through a JSON data structure, but this structure is a dictionary composed of nested dictionaries so after analyzing JSON with json.loads() for the items using…
-
2
votes3
answers107
viewsA: how to compare whether a dataset of an array contains in the other javascript array
If you want to find the index of an element within an array use the method Array.prototype.findIndex() which returns the index of the first element in the array that satisfies the given test…
javascriptanswered Augusto Vasques 15,321 -
1
votes1
answer38
viewsA: How can I remove 'R$ xa0' from a obtained result?
If the goal is to remove from a string the Brazilian currency symbol and the thousand separator point, for each of the strings take a slice of the fourth character at the last to remove the real…
-
3
votes1
answer99
viewsA: Where in a select on a system using a many relationship type for many
Make a filter using the clauses: WHERE nome_da_coluna IN(valor+): Where the clause WHERE determines which lines should be returned according to a criterion, operator IN allows you to specify a set…
-
0
votes2
answers80
viewsA: How do I check which items in List2 are in List1, then their count and order
The approach you used is not the most efficient because for each element of Lista2 you had to write a specific code to perform the comparison and addition of the element to Lista_ordenada, case…
-
0
votes2
answers35
viewsA: SQL SERVER - Changing different records in a field based on another field
One possibility is to use the analytical function FIRST_VALUE() to returns the first value in an ordered set of values partitioned by the data of a specified column. Data set for the test: CREATE…