Posts by Elton Nunes • 490 points
28 posts
-
0
votes3
answers34
viewsA: Error clicking the Tkinter Python button
from tkinter import * win = Tk() win.geometry("400x150") class Application: def __init__(self, master=None): self.title = Label(master,text="Please enter the username and…
-
0
votes2
answers45
viewsA: Tkinter and class
The problem is in the use of two layout managers that is being used in the script pack is one, and place is another, the same object should not use both at the same time, at the moment do not…
-
2
votes1
answer46
viewsA: Send all returned data in the same email
super simplified you’re doing it for linha in banco if linha enviaEmail you must do variavel for linha in banco if linha variavel concatena linha enviaEmail…
pythonanswered Elton Nunes 490 -
0
votes1
answer45
viewsA: Duplicate files
with open('Pedentes.csv') as pendente: arq1 = pendente.readlines() with open('Cancelados.csv') as cancelamentos: arq2 = cancelamentos.readlines() with open('resultado.csv', 'w') as res: for i in…
-
1
votes2
answers52
viewsA: Switcher in python with Get
will not work because a dictionary does not have repeated keys, try so op = {1 : 'teste', 2 : 'outro teste', 3 : 'mais um teste'} escolha = 1 print(op.get(escolha))…
-
1
votes1
answer95
viewsA: Tkinter error on a label object
solved the problem by reversing the inheritance in your code you create class Janelas class Autenticar(Janelas) if you reverse to class Autenticar class Janelas(Autenticar) and correct the call of…
-
2
votes1
answer187
viewsA: How to discover all possible paths to visit all vertices of a graph?
having the graph defined in the image it has no restriction, I chose to use a dictionary (Vertice:exits) to represent it grafo = { '1' : '234', '2' : '134', '3' : '124', '4' : '123', } found the use…
-
2
votes1
answer454
viewsA: Creating a covariance program with Python
I did the exercise following this example in wikihow I left it very raw for you to see my step by step, and it’s one thing I recommend to do when you’re training, you run the code every line you add…
-
1
votes2
answers100
viewsA: What is wrong with python below? Any suggestions for another solution?
your problem this on this line, it may change the length of the list but as this inside a codition is not always it will make this change that causes the problem. matriz[i].remove(maior) I’ve made…
-
0
votes1
answer99
viewsA: How to improve the time cost of the algorithm - Python
following the entry and exit of the exercise, the initialization of the initial lists becomes costly dicionario = [0] * n palavras = [0] * m what happens is that a single position list is created…
-
3
votes1
answer71
viewsA: Orientation to Python Objects
I think you should make the Setter and getter another way, I made a simple example for demo class GetSet: def __init__(self, arg): self._valor = arg @property def valor(self): return self._valor…
-
0
votes2
answers87
viewsA: Problem involving classes, vectors and tuples
I believe the first problem you’re having is how to use the first class created, Turma it receives two arrays, but you are passing from unitary values, I believe it should be instaciated this way…
-
0
votes4
answers1240
viewsA: I want to take only the first digit after the point of a number that in python 3.7.4
vc can do either mathematically or with type conversion, in this case converting to string and editing n = 3.76443 ns = str(n) ponto = ns.find('.') print(ns[ponto+1]) n1 = n - int(n) n1 *= 10 n1 =…
-
2
votes2
answers81
viewsA: Python: Return a list in 2D format
as Anderson has already pointed out in the comments, you should implement the function __str__, however what gives a intender in your duvia is that you want a feedback when creating the list, that…
-
1
votes3
answers3860
viewsA: What is the python float
input takes a user keyboard input, and returns a string. '1.5' would be the representation of a kilo and a half, but it is in quotes, characterizing a string, and if this value is used in a…
-
1
votes1
answer26
viewsA: Larger Image than the Frame
take the output of the so-called Image.open, and create another rescheduled image image = Image.open("barra.jpg") image2 = image.resize((100, 100))
-
1
votes2
answers1552
viewsA: How to show an image on Tkinter?
see two mistakes The first one here self.imagem['image'] = ImageTk.PhotoImage(Image.open("bola.jpg")) what happens is that Imagetk.Photoimage is being picked up by the garbage collector, the…
-
0
votes1
answer77
viewsA: *Python , discounted calculations are giving a wrong value, why?
the correction for this if using parentheses to separate if conditions if (cadastro == 'D' or cadastro == 'd') and quantidade <= 20 and (tipo_comb == 'G' or tipo_comb== 'g'):…
-
0
votes1
answer2078
viewsA: Calendar in python
the problem lies within the if if operacoes == 'adicionar': print("\nOpção ADICIONAR selecionada") adicionar1() inserir_telefone() inserir_endereco() the add function creates the file, writes and…
pythonanswered Elton Nunes 490 -
-2
votes2
answers707
viewsA: Are class methods recreated for each instance in Python?
if curious, I suggest using function to create function. my suggestion is the following code class Foo(): x = 5 def __init__ (self): self.x = 10 self.setFoo = self.setarFoo() def getFoo(self):…
-
2
votes1
answer82
viewsA: How to read the following code in python?
The first part of if: len( ) #1 set( ) #2 vec[i]+i for i in cols #3 Line 3 creates a iterator which returns the position value i in the vec plus the position value i in cols. Line 2 converts line 3…
-
0
votes1
answer205
viewsA: Column Python function for a list
banco = [['Carlos', 'M'], ['Frenanda', 'F'], ['Gilberto', 'M']] def column_to_list(data, index): column_list = [] for pessoa in data: column_list.append(pessoa[index]) return column_list generos =…
-
2
votes2
answers301
viewsA: Changing data types in a Python list
acs ñ esta declarado using append lista = [1,2,3,4,5,6,7,8,9,10] acs = [] for i in lista: acs.append(float(i)) using map lista = [1,2,3,4,5,6,7,8,9,10] acs = [*map(float, lista)] using understanding…
-
0
votes1
answer276
viewsA: Python - Tkinter Grid
ola, to achieve the effect just put one more frame, using grid you should look for nesting frames from tkinter import * class Main(): def __init__(self, master = None): self.topFrame = Frame(master,…
-
-3
votes3
answers1165
viewsA: Pass a variable from one function to another
Like everything in python is an object, ñ functions could be different def envia(arg): recebe.valor = arg def recebe(): print(recebe.valor) >>> envia(2) >>> recebe() 2…
-
3
votes4
answers242
viewsA: What’s behind the "go"?
python has the iteration protocol, where all the sequence is an iterable, the proof of this is the implementation of the method iter in the object dir('teste')#vc vai achar __iter__ no meio dos…
-
0
votes3
answers5733
viewsA: How to save the output result of a Python script to a txt file?
vc opens an open file using the 'w' flag, and vc can make a change to the print to send the information to the archive instead of the terminal arquivo = open('arquivo.txt', 'w') print('informação',…
-
-1
votes2
answers162
viewsA: Identify zero sequences in a csv file using python
you can create an empty dictionary or already with all users, and all pointing to the zero value when you iterate the file and if the value is zero, vc will add 1 to the corresponding user in the…