Posts by Evilmaax • 2,613 points
115 posts
-
0
votes1
answer46
viewsA: While repeating structure does not repeat specific code snippet!
Actually your code is running correctly according to what it was programmed, it just isn’t doing what you want because you haven’t programmed as it should. Your mistake is as follows: In line 8 you…
-
-1
votes1
answer85
viewsA: Error <Generator Object <genexpr> when reading Python matrix
You need to use an object tuple() or list() to convert the result of the expression that is generating its matrix, more precisely in its for. code working: leia = input('Digite a dimensão da matriz:…
-
-1
votes2
answers29
viewsA: When trying to extract a PDF using Python Textract, returns an error
This error is caused because you are using a normal string as a file address. There are 3 possibilities to solve: 1: Add r before the string to convert from normal to normal raw string: text =…
-
1
votes1
answer32
viewsA: Frame one image within another
Sizing with fixed values will not work at all. To keep the ratio you have to do a small calculation. First you have to take the desired width and divide by the width of the original image, so it…
-
1
votes2
answers59
viewsA: Create Dataframe from lists with different sizes, keeping the data matching
you can do this with the following code: pd.DataFrame({'Cliente': pd.Series(cliente), 'Nota': pd.Series(nota), 'Código': pd.Series(codigo), 'Valor': pd.Series(valor)}) Exit: Cliente Nota Código…
-
1
votes2
answers35
viewsA: I’m making webscraping with python and can’t break a loop
Your error is simpler than it seems: You didn’t put a condition where the variable continuar flipped False, so the code keeps repeating endlessly. To solve I added the line continuar = False after…
-
0
votes1
answer36
viewsA: Attributeerror: type Object 'User' has no attribute 'order_by' - Sqlalchemy
You are giving this Exception because you made a typo by typing "oder_by" instead of "theRder_by". Since the command does not exist, consequently its object does not have this attribute, generating…
-
0
votes1
answer17
viewsA: Save the number of rows of a dataframe to a variable
If I understand correctly you want to replace that 10 fixed by the number of lines that were generated randomly in its dataframe, that’s it? In this case you can use the method shape which shows the…
-
0
votes1
answer37
viewsA: Exercise - Taking time in seconds and returning to the average and lower values to the average
You just need to go through the list by making one if. If it is less than the average printa, otherwise. Something more or less like this: lista = [] segundos = int(input()) while segundos >= 0:…
-
1
votes3
answers77
viewsA: Generate multiple different arrays containing random numbers
Can’t you use an auxiliary list? If possible, it’s quite easy: Create this list and, after generating the random number array, do a check, if the sequence is unique it is inserted in your array,…
-
1
votes3
answers193
viewsA: Take values less than or equal to 500 from the list - Python
To do this you have to go through the values of your list and if it is less than or equal to 500 add to a second list. Then, to make the average just tame all the values of the second list and…
-
1
votes1
answer44
viewsA: How do I apply a condition to a line that skips the next line? (python beginner)
Simple, Eric. In your case it’s just encapsulating the n2 in a if and test the operation. If the value is not */, that symbolizes its square root, then the line is executed, otherwise it will be…
-
1
votes2
answers130
viewsA: Show Python words with 04 letters only
Your code to validate the words with 4 letters and display them is correct, the problem is that you are running only once the code, ie stores 1 name, displays (or not) and successfully finishes the…
-
-1
votes1
answer87
viewsA: Insert line break based on number of characters avoiding cutting words
As you said you are starting here I will do well didactic, but you can simplify my code much more (for example, starting the count at 0, as is the standard of most programming languages and counting…
-
0
votes3
answers146
viewsA: How to use double quotes in a python application by running a subprocess
To escape the double quotes wrap the entire content with single quotes. For example: Insira nome da rede: jimi Insira a senha: yay echo 'network={ ssid="jimi" psk="yay" key_mgmt=WPA-PSK }' Another…
-
0
votes4
answers573
viewsA: how to create a list of multiples of numbers of 3, from another list of numbers?
Your problem was having the print out of the loop if. Since the value of variable C is the condition to print or not the line (if the number tested is a number divisible by three) and as this value…
-
0
votes1
answer977
viewsA: Scatterplot trend line in Python matplotlib
You can do this quickly through polyfit function of numpy. import matplotlib.pyplot as plt import numpy as np x = [548, 677, 987, 2, 29, 1114, 521, 999] y = [96, 775, 258, 369, 410, 99, 5, 1117]…
-
0
votes1
answer30
viewsA: Doubt last line in VBA
In this case the results are correct. If you take the first line - Sub DINAMICO() - You’re taking the signature off the function, which is what it tells the language where the code starts. No…
-
2
votes1
answer42
viewsA: Align the contents of the div to the center, but the texts are on the left
First, create a core div that will center your child content with text-align: center. Then raise a div child who uses display: inline-block to adapt to the width of their children and text-align:…
-
3
votes3
answers116
viewsA: error in Count function
You just made a mess of the list syntax. When you will call the same to query some value, as the votes for each OS, you should not put your name between []. Soon just remove them that will work:…
-
0
votes2
answers28
viewsA: Ordering result
To sort a dictionary in Python is very simple since the language has its own method for this that works with both dictionaries, such as lists and tuples. The syntax is sorted(object, key, reverse),…
-
0
votes1
answer617
viewsA: Error reading csv file in Python
According to its error log, the parser is having problems on line 218 when it expects only 1 field with data (1 cell in the language of .csv) and is getting 4. I can think of 2 solutions: The first…
-
0
votes1
answer139
viewsA: Error running Keras.models.Sequential() with tensorflow
I don’t think your problem is with the Sequential, but with the Backend. Supersedes the from keras import backend for from tensorflow.keras import backend If you want to read the issue github click…
-
2
votes2
answers242
viewsA: What is In[]: and Out[]:?
Probably the tutorials you are seeing are being programmed and run in environments like the Jupyter Notebook. JN is a virtual environment for code education as it makes it easier visually to teach…
-
0
votes2
answers122
viewsA: I have a job in Python 3 and do not know how to proceed
Your code is experiencing several basic problems. For example: You are reading 20 numbers on for initial and then initializing 3 times in a row the variable numeros. It’s right to do everything…
-
5
votes2
answers3924
viewsA: Change language on github
Github uses the library Linguist to determine the percentage of each language in a project and generate that way bar up there, however, it is not fault free. The quickest method to solve this is to…
-
0
votes1
answer284
viewsA: How to return the selected item from a spinner
In case someone is going through the same problem, I solved it as follows: Instead of int with the position I returned the position value for a string. And the list populating my spinner had to be…
-
1
votes1
answer34
viewsA: Average of 2 values followed by a list
As you are using a list of indefinite size just iterate with a while making the average of the current position + the next position. The loop closes when it reaches the position of tamanho da sua…
-
-1
votes1
answer284
viewsQ: How to return the selected item from a spinner
How to pass to a variable the value selected in a spineer at the moment the user selects some of the options? I tried to implement this option, but I was unsuccessful. Follow my code in case anyone…
-
1
votes1
answer55
viewsA: How to get information from Excel cells using VB
You can make a loop for which reads the value of the variable, stores and skips a line down; if the next line is empty it stops and exits the loop, otherwise it continues. In the example below I did…
-
1
votes2
answers184
viewsA: Difficulty to loop in VBA
If the code is working for an individual run, all you have to do is run it indefinitely while some condition is true. For example, while the column Base has records, it runs to that line. When it…
-
0
votes1
answer335
viewsA: Convert CSV to xlsx, in vba
The answer is in your own code. Note the following line where you have instructed what Excel has to consider and disregard: TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _…
-
-2
votes2
answers873
viewsA: How to know if a number is an integer or a float? And how to assign a type to a value inserted in the input function
Really the way the hkotsubo said it is better, more practical and more pythonic. But just for registration title: Yes, it is possible to check if a number is float and you can do this in different…
-
1
votes2
answers133
viewsA: Unify multiple worksheets from different workbooks
I’m in college and now I won’t be able to continue, but it’s something along those lines: Sub Unificar() Dim sPath As String, sName As String, fName As String Dim r As Long, rTemp As Long Dim…
-
2
votes1
answer587
viewsA: Replace VBA method
I found out. It was very simple. I just needed to assign another variable first. It looks like this: Cells(endereco(linhaAtual).Row, 19) = Replace(Cells(endereco(linhaAtual).Row, 19), item.Value,…
-
1
votes1
answer587
viewsQ: Replace VBA method
I would like to know how to use the method Replace with dynamic variables in VBA. My line is : Replace (Cells(endereco(linhaAtual).Row, 22), item.Value, "") In this case the variable where the…
-
4
votes4
answers138
viewsA: Count inside an array with values from another array
Python has a native function called Count() which, as the name says, accounts for. So it’s much simpler to run it inside a for for each of the items on your list nomesand print the amount of them.…
-
5
votes4
answers5082
viewsA: What does /= mean in Python?
The //, call for floor Division, ignores the rest of a division and returns only the whole of the result. For example: x = 17 // 3 print(x) >> 5 Other examples: 5 / 2 = 2.5 (2) 5 / 7 =…
-
0
votes4
answers1240
viewsA: I want to take only the first digit after the point of a number that in python 3.7.4
If you want to import the library math I can do this: import math numero = 3.76443 fracao=math.modf(numero) fracao=str(fracao[0]) print(fracao[2]) In the above case Using you will be using the…
-
4
votes1
answer62
viewsA: Excel with Conditional Formula per month
Its formula contains some wrong things, for example those + loose in the formula and the wrong use of and. To use a and or or correctly you have to put them at the beginning of the function they…
-
2
votes1
answer44
viewsA: Modify Sheet killer to just clean sheet content and not erase it completely
Follow the complete code with the modification: Sub Listar_Pastas() '''''''''''''''''''' '==== Pastas ====' '''''''''''''''''''' Application.Calculation = xlCalculationManual…
-
0
votes2
answers181
viewsA: Import of python modules
When you set a variable in a function, it is only accessible in that capacity. Therefore, the data defined in def json() is not available in the context of your Selenium.py. To provide information…
-
2
votes2
answers165
viewsA: Variable appears as undeclared when trying to use it in the "while" loop
The difference between the while "normal" and the do while is that in the do while the loop will always be executed at least once. Thus, the test variables have to be declared before the loop…
-
1
votes1
answer513
viewsA: How to create a hash using the hashlib library using the "time.time()" method in Python3
Your strings are in the wrong format. They must be encoded before hashing through one of the following methods: (str1).encode('utf-8') or num1 = b'123456' Or you can do everything in one line only…
-
2
votes1
answer58
viewsA: Requesting Privileges in Windows with python
You cannot change the privileges after launching a run on Windows. What you need is to ensure that the application runs with administrator privileges and not as a normal user. What you can do is…
python-3.xanswered Evilmaax 2,613 -
0
votes1
answer68
viewsA: compare string
How your input is of the type str even if the user type 12345, for example, the program will not understand how int. So I suggest creating a variable and putting in there everything you want not…
-
2
votes1
answer458
viewsA: What is the equivalent of "from" and "import" (PYTHON) in Ruby?
To include modules, classes, etc in other files you have to use the require_relative or require (require_relative is a more "rustic" way of programming. ) For example the following module: module…
-
1
votes1
answer274
viewsA: Installing libraries from the linux terminal
The versions are even separate and install in one will not install in another. To install specifically for Python 3 just use pip3 install alguma coisa
python-3.xanswered Evilmaax 2,613 -
0
votes1
answer274
viewsA: Expected Primary-Expression before"int" - C
The problem is that you are making confusion between vector declaration and vector passage as parameter. When you declare the vector with float massa_corporal[3], peso[3], altura[3]; the program…
-
0
votes1
answer77
viewsA: Open URL Waze (maps) using Android webviewer
Error of scheme represents an error with the URL prefix, with what comes before the address itself, as http: https: ftp: sftp, etc.. Check the address you are passing. I’m not sure which pattern to…