Questions tagged as 'python-3.x'

2
answers

Python, Cipher of Caesar, Strings

Hello, I would like to ask some tips to improve the code, especially in the 'geraMsgTraduzida' function, to make the code look better if it is possible. def recebeModo(): """ Função que pergunta se o usuário quer criptografar ou de...
asked by 15.09.2018 / 03:57
1
answer

Sort list with Python + Django

Good afternoon guys, I'm having a problem, I've registered for the django admin a video that should be sent to my template, but I need these videos to be sorted by the position field I have in my models.py in the bank models.py...
asked by 27.09.2018 / 16:30
2
answers

Python - libraries without the import "*"

How do I create a library without having to import like this: from x import * or from x import y ? Only by importing import x . Who can answer me, please use the script below as a library example. def imprimir(): prin...
asked by 07.09.2018 / 04:33
3
answers

Restart application in Python

How do I restart my program with Python? cpf = input('Digite os nove primeiros dígitos do CPF: ') if len(cpf) != 9: # Aqui deve reniciar a aplicação.     
asked by 03.03.2017 / 04:04
1
answer

Problem in python's print

I have 2 inputs that receive the first and last name of a person, then the values entered are entered and the age is requested, but the print is showing name information between " Brackets ". How can I remove? This is the output Type yo...
asked by 01.01.2019 / 17:57
2
answers

Calculation of occurrence of strings in list - Python

Personal I need a help to calculate the number of occurrences of a given string in a column of a list. Example: test_list = [['Name', 'Age', 'Sex', 'Occupation'], ['Peter', '25' em> Ex: Calculate the number of occurrences by profession --...
asked by 06.05.2018 / 03:01
1
answer

Python - Sort list strings by number of ascending letters

Having the following list: lista_nomes =['Manuel', 'Laura', 'Antonio', 'Jasmim', 'Maria', 'Silvia', 'Lu', 'Pancrácio', 'Diogo', 'Ricardo', 'Miguel', 'Andre'] And wanting to sort it by increasing number of letters. Now, I'm not getti...
asked by 02.05.2018 / 10:24
1
answer

How to write an alphabetical list of names using the Python OrderedDict?

Nomes = [] Telefones = [] Endereços = [] Emails = [] Agenda = {"Nome": Nomes,"Telefone":Telefones,"Endereço":Endereços, "Email": Emails} entrada = "" print("Bem-vindo a nossa Agenda!!!!!") while entrada != "s": nome = input("Digit...
asked by 07.04.2018 / 00:43
1
answer

Comparison of values in list of tuples in python 3.x

My question is how can I interact with this list in order to make comparisons between values. def trocar(vals, posX, posY): temp = vals[posX] vals[posX] = vals[posY] vals[posY] = temp return None def ordenar(valores): tam...
asked by 08.04.2018 / 06:55
1
answer

Bytearray size on disk

Let's suppose I convert any image to bytearray . with open("img.png", "rb") as imageFile: f = imageFile.read() b = bytearray(f) print b[0] How do I know how much disk space this bytearray will occupy if I decide to save it...
asked by 03.07.2018 / 22:22