Questions tagged as 'python-3.x'

1
answer

Access variable through exec

I was trying to create a shell to be able to communicate with a program in python during its execution, so far I have the following (this code is just an example): import sys, pygame from threading import Thread import math pygame.init() # I...
asked by 12.02.2018 / 13:12
1
answer

Why is the text label unchanged?

I have the class of a screen, which contains a text label, the code loads an xml containing the objects. tela.py: #!/usr/bin/python3 import gi import modulo_arquivos import os gi.require_version("Gtk", "3.0") from gi.repository import Gt...
asked by 26.02.2018 / 21:00
1
answer

How to retrieve the return of a function that was executed inside a Thread in Python3?

I need to run a function through a Thread only so I'm not sure how to retrieve the return from this function. Here's an example of how I want to do it: from threading import Thread import time def teste_thread(): for k in range(5): prin...
asked by 26.02.2018 / 22:21
1
answer

How do I prevent user input from resulting in a ValueError, and ask the program to rephrase the [duplicate]

I need to learn how to check if the input will result in a ValueError, and then re-execute the input request until the value is an integer. My problem: QuantidadeCabos = int(input("Digite a quantidade de cabos: ")) If the user types a...
asked by 03.04.2018 / 20:04
4
answers

Comparison between random number and typed number never says you got it right, even the numbers being equal

I'm trying to make a program where I can type a number n and then I would like to generate a random number between 1 and 2. If this random number is the same as n , it would show "You won!" and if not, "You have lost." But even when...
asked by 15.02.2018 / 04:22
1
answer

Is it worth doing exercises that teach not very optimized ways to make a program? [closed]

Well, I'm learning python and sometimes I come across some relatively difficult exercises, for example, an exercise where the program had to read a cash value and say how many 1, 5, 10, 20, 50 , 100 that money could be represented. The proble...
asked by 23.02.2018 / 02:46
2
answers

Python 3 and Tkinter: progress bar does not update during script execution

Hello. I'm creating a layout converter using Python 3.6.4 and Tkinter. Among other things, the GUI should have a progress bar that updates its value with each interaction of the conversion process, for example, every processed line of the fil...
asked by 12.03.2018 / 19:01
2
answers

Strings in python [closed]

I know the basic encoding of strings in Python, but I still can not move forward and complete the whole requirement of the statement. I do not know how to code the quantities you require in the question. Follow the sentence: Read keyboar...
asked by 06.03.2018 / 15:11
1
answer

What problem can occur when retriggering a value without having a variable to receive (Python)?

If I have a function that returns a value or True and False, but does not have a variable to receive, can this cause some problem in the code operation? Example: def Retorna(): return False def Retorna2(): return 100 Retorna() Ret...
asked by 22.01.2018 / 13:26
1
answer

How to modify a list inside a method in Python?

Suppose I have the following method and the following list: def ModificaValores(Valores): dados = [6,5,4,3,2,1,0] Valores = dados Valores = [0,1,2,3,4,5,6] print(Valores) ModificaValores(Valores) print(Valores) Why in the out...
asked by 22.01.2018 / 12:22