Posts by Natan Fernandes • 560 points
35 posts
-
0
votes1
answer38
viewsA: How to improve a calculator
You can create a function to do it for you, something like that: public double ReadNumber() { var str = Console.ReadLine(); while (!str.All(char.IsDigit) || string.IsNullOrEmpty(str)) {…
-
0
votes3
answers42
viewsA: c# - Update excel spreadsheet with textbox text
Are you looking for the Cod as if it were a string and it is not a string but a number. Remove the quotes and should work: command.CommandText = "update [Designa$] set Nome = '" + textBox1.Text + "'…
-
2
votes1
answer40
viewsA: Search by name in spreadsheet C#?
You forgot the quotes (') time to look for the string name. This should work: _oleCmd.CommandText = "SELECT Nome FROM [Designa$] Where Nome='" + textBox1.Text + "'"; Or _oleCmd.CommandText =…
-
0
votes1
answer32
viewsA: Movement of ghosts in Pacman
Your function needs to return one Booleano. The error says that your function is not returning any value, and it really is not. To resolve this error you can do so: Public Function…
vb.netanswered Natan Fernandes 560 -
0
votes2
answers45
viewsA: I need to count a number of specific numbers per column in a matrix
Surely there is one more way pythonica to do this but this was my solution: mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1,…
-
0
votes1
answer29
viewsA: SWIG - How to convert primitive types that are passed by reference?
After a lot of research and help from the paroj of Ogre3d, got! What I did to fix it was this, I used the %apply and stayed like this: %apply unsigned short& OUTPUT { unsigned short&…
-
0
votes1
answer29
viewsQ: SWIG - How to convert primitive types that are passed by reference?
I’m using SWIG to be able to use a C++ code in C# (Ogre3d for the curious) I have the following method in C++: bool suggestTangentVectorBuildParams(VertexElementSemantic targetSemantic, unsigned…
-
0
votes1
answer39
viewsA: Problem with a counter adding numbers inserted in C
Where is the problem? Your code has 2 problems: Is adding to the sum values that are also negative or zero. Is dividing the sum by 6 and not by all positive numbers. How to solve? Put the sum part…
canswered Natan Fernandes 560 -
2
votes1
answer677
viewsA: What does Please Tell me who you are in git mean?
That means Git doesn’t know who you are. To work it needs an Email and a name to identify you. But why? Git uses your email address to associate your name with any commit of your own. After…
-
0
votes4
answers109
viewsA: Define the lowest and highest value among three numbers
You can also use a list and sort it, but it is much slower depending on the case than compare with comparison operators. // Declarando a lista List<double> lista = new List<double>(); //…
-
2
votes1
answer30
viewsA: Incorrect exit in practice
Your problem is in the last loop repeat, try to do this way: for (int i = n-1; i >= 0; i--){ printf("Os numeros pares sao %i\n", par[i]); } I put i = n-1 it gives 9 (the vector has 10 positions…
canswered Natan Fernandes 560 -
1
votes2
answers49
viewsQ: Result of the same account is different in VB and C#
I’m trying to use a formula that gives me the expected result in C#, when translating the code to VB.NET the result is completely different. I’m almost sure I did the translation correctly. I forgot…
-
1
votes0
answers31
viewsQ: Why (0.1 + 0.2 - 0.3) is 5.55111512313e-17?
It seems pretty obvious to us humans that 0.1 + 0.2 - 0.3 is 0 but why when I ask the Python interpreter to perform the following operation: print(0.1 + 0.2 - 0.3) he returns 5.55111512313e-17? It’s…
-
0
votes3
answers129
viewsA: Catch internal IP via Python (Router)
In Windows, you can achieve using the netifaces, you can install it by Pip and will need the Microsoft Visual C++ 14.0: import netifaces gateways = netifaces.gateways() gateway_padrao =…
-
2
votes2
answers51
viewsA: "Argued tofrangeexception" error when performing database query to return quantity of records
The cooperado is coming empty because there is no record. One simple way to resolve this is with a if: var cooperado = ExecutaComandoComRetorno(comando); if (cooperado is null) // Se não tiver…
-
0
votes2
answers102
viewsA: How to create a function that counts the characters of a sentence and shows the frequency of one?
I made the algorithm according to @anonimo’s idea: #include <stdio.h> #include <string.h> int main() { char* frase; fgets (frase, 256, stdin); // Verificando se o último caracter é uma…
canswered Natan Fernandes 560 -
0
votes1
answer25
viewsA: System Login - Py error
Note that in function login() you say password is a string, but in if you compare as a number: password = str(input('Password: ')) if user == 'admin' and password == 123: To solve the problem just…
-
0
votes1
answer32
viewsA: Automatically put words in a list
If the words are separated by space you can do so: lista = [] entrada = input() palavras = entrada.split(' ') for palavra in palavras: lista.append(palavra) print(lista) Entree: Estou fazendo um…
pythonanswered Natan Fernandes 560 -
2
votes2
answers183
viewsA: remove the first and last character of a string in C
You can use the function atoi() library stdlib.h. This function takes the numbers from the string and transforms them into integer. Example: #include<stdio.h> #include <stdlib.h> int…
canswered Natan Fernandes 560 -
0
votes1
answer38
viewsA: Error C# System.Indexoutofrangeexception
The mistake really isn’t in the Convert.ToSingle() yes in its loop of repetition. The indices of an array start at 0 and not at 1, so when you arrive at the last iteration will give the error…
c#answered Natan Fernandes 560 -
0
votes1
answer21
viewsA: Binding of an Image in the Preject Resource
You can use Resource Manager: ResourceManager rm = Resources.ResourceManager; Bitmap icone = (Bitmap)rm.GetObject(Condition.WeatherIcon.ToString() + ".png");
-
0
votes1
answer41
viewsA: Losing values entered in the list after exiting the method (C#)
Note that you are creating a new list each time you select an option in the loop. To keep the desired list you should declare the list of books out of the repeat loop. List<Book> bookList =…
c#answered Natan Fernandes 560 -
0
votes1
answer31
viewsQ: How to 'scroll' a panel to the end? Javascript + ASP.NET
I have an ASP.NET panel that shows recent messages and I want the scroll to always remain at the end (messages are from bottom to top, as in Whatsapp). My problem is that I can’t at all make the…
-
1
votes1
answer243
viewsA: How to change the color of items in a list in Python?
You can color the prints with the colors you want, the color codes are these: Azul = '\033[94m' Verde = '\033[92m' Amarelo = '\033[93m' Vermelho = '\033[91m' Fim = '\033[0m' In the prints: print…
-
0
votes1
answer239
viewsA: How do I send an error message? Discord.py
You are giving this error because in the command constructor the "user" parameter is required. To leave it optional it should look like this: user: d.Member = None
-
0
votes2
answers581
viewsA: How to pass python variable to sql query?
You can use Python fstrings and concatenate the variable in the query string query = (f'INSERT INTO tabela_ficticia(coluna_nomes) VALUES ({variavel_nome_cliente})') Note that the variable is between…
-
0
votes1
answer71
viewsA: Add object validating if it exists
In Python to check if an object exists in a list is very simple. I believe that in your code would look like this: def add_viatura(self, new_v): # verifica se existe a viatura na lista 'gestor'…
-
0
votes4
answers412
viewsA: How to check if a list contains 3 consecutive numbers
Inside the loop I would do something like this: if i+2 < len(A) -1: if A[i] == A[i+1] -1 and A[i] == A[i+2] - 2: contem_consecutivos = True First I see if there are 2 numbers in front, if there…
-
0
votes1
answer42
viewsA: Correction code portugol
You forgot to open keys after conditions. You also only need to read the variable n1 once instead of reading several times and assigning the value in a different variable. That would be your code:…
portugolanswered Natan Fernandes 560 -
0
votes4
answers326
viewsA: How to change the value of an object array?
I did it with a loop going through the entire list, see if it works and if you can understand how it works const usuarios = [ { nome: 'Diego', idade: 23, empresa: 'Rocketseat' }, { nome: 'Gabriel',…
javascriptanswered Natan Fernandes 560 -
0
votes1
answer438
viewsA: swap decimal separator in python
If you need a string, you can simply replace the point with a comma with the replace(), but I don’t think it’s very viable if you have to do it over and over again. numero_com_ponto = 123.45…
-
3
votes1
answer39
viewsA: How to convert 2,22292E+12 to 2222921601281
You can use decimal instead of float to obtain a more precise result. Floats and doubles work with rounding values, so they wouldn’t be a viable option to calculate mmc, because you need an exact…
-
0
votes2
answers106
viewsA: Tabulate Python
You must exchange data['Clients'] = input('Digite: ') for data['Clients'].append(input('Digite: ')) , this way you will add a new account and will not skip line Code with while True: from tabulate…
python-3.xanswered Natan Fernandes 560 -
0
votes1
answer578
viewsA: Trying to create a python Discord bot
I had this same problem, the only way I could solve was by installing a certificate(?) on my computer. You can download it here: https://crt.sh/? id=2835394 The download button is half hidden but is…
pythonanswered Natan Fernandes 560 -
0
votes3
answers112
viewsA: Restart application - Python
You can use while’s instead of if’s and then it will only pass this part when the values are valid. while True: print("Utilize apenas valores com ponto, e não virgula!" '\n') tipo = input ("1020,…