Questions tagged as 'python-3.x'

1
answer

Saving past data - Django

My question is as follows, in my application I have a Profile template that has the following fields: Models.py: class Perfil(models.Model): nome = models.CharField(max_length=255, null=False) pontuacao_total = models.FloatField(max...
asked by 02.04.2018 / 00:49
1
answer

Python - print list elements that have 5 letters

Good, Having the following list: lista_nomes =['Manuel', 'Laura', 'Antonio', 'Jasmim', 'Maria','Silvia', 'Lu', 'Pancrácio', 'Diogo', 'Ricardo', 'Miguel', 'Andre',] I want to print the elements of the list that have 5 letters. It turns ou...
asked by 01.05.2018 / 13:35
1
answer

Message in "print" is not printed on the screen, how to correct? [closed]

The print message does not appear on the screen, does it relate to the variable? cp = str input("seu nome") if(cp)=='jefferson': print('JFP')     
asked by 02.11.2018 / 18:34
2
answers

Convert search with PyMongo: Dictionary in JSON

I'm using PyMongo to do a search: resultado = db.find_one({'nome':'xpto'}) The result of this search is a dictionary in Python, but I need to convert it to a JSON. What is the best way to do it?     
asked by 04.12.2014 / 18:21
2
answers

Handling items during iteration

In Python it is somewhat common to go through items from an iterable handle or checking for the existence of a particular item, or whatever the operation. I'm reading the Python documentation again and I come across something that when seen fo...
asked by 20.11.2018 / 23:47
2
answers

How to put more than one parameter in Python?

I'm learning Python3 and I'm having trouble making a Python implementation. For example, in C: for (fatorial = numero; fatorial >= 1; fatorial--) I want to put this above implementation in python: I already did this: for (fatorial...
asked by 23.08.2017 / 01:00
5
answers

Intersection between two sets (element that is in set A and B at the same time)

I'm trying to do a function that returns the intersection between two sets: def intersecao(conjuntoA, conjuntoB): inter = [x for x in range(1,12) if x in conjuntoA and conjuntoB] return inter a = [2,4,6,7,10] b = [3,4,6,8,10,11] print...
asked by 26.08.2017 / 01:07
1
answer

Python builder with ** kwargs

I would like to know if the use of ** kwargs in a constructor is the best alternative or if there is a better path for cases similar to the ones below: class Duvida(object): def __init__(self, **kwargs): self.formato=''...
asked by 07.12.2017 / 18:53
2
answers

I would like to know why python is saying that I have provided 3 arguments in this function?

Code: print("Jogo do chute...") import random numeroaleatorio = random.randrange(100) chutes = 0 r = True while r: chute = int(input("Digite um número de zero(0) a cem(100): ")) if chute > numeroaleatorio: print("Número m...
asked by 05.07.2017 / 20:26
3
answers

Adding text files with python

I have a series of files in .txt and would like to sum them all together using a script in python. something like: #Abre o arquivo que receberá a soma de todos os outros arq.open("redação.txt", "w") #escreve todas as linhas de cada arquivo...
asked by 26.05.2017 / 03:33