Questions tagged as 'python'

2
answers

How to set a private property in Python? Is there protected property?

I come from PHP. In it, when we want to define a property of a class as private we add the keyword private in its declaration. Example: class StackOverflow extends StackExchange { private $language = 'en'; // privado, só pode ser...
asked by 04.03.2015 / 20:56
1
answer

If possible, how can I work with integer values with 1 million digits or more in python?

I'm running some experiments with prime numbers and needed to process huge integers, however when trying to process a small routine an error occurs in the following line:   OverflowError: int too large to convert to float How can I...
asked by 14.09.2018 / 13:20
2
answers

How to change the value of a variable through function in Python?

How can I change the value of a variable through a function? Here's an example of what you'd like to do: def func(t): t = 2 + 3 t = 7 func(t) print(t) The output of the print (t) function returns me the value 7 and not 5 as the desired...
asked by 04.08.2017 / 22:46
1
answer

List being modified without implementation

I have a problem where the list I am working on is being modified even though there is no passing of values to it. from random import * from numpy import * m=2 lista_inicial=[[1, 2], [0, 2], [0, 1]] lista_aux = [] lista_aux = lista_inic...
asked by 14.09.2016 / 14:11
1
answer

Extract index for repeated elements in lists in Python

If I have a x list that contains multiple values, and a few repeats, and I want to have the index for each element, how can I do it? I tried doing it using the .index() method but it only returns the index of the first element. &...
asked by 17.09.2016 / 17:26
1
answer

How to get the HOST IP through the domain in PYTHON?

In PHP, to get the ip of a given domain, I usually use the gethostbyname function. PHP example: gethostbyname('www.google.com'); //201.17.165.210 What about Python? How can I do this?     
asked by 20.07.2016 / 18:19
1
answer

Hangman Game in Python

I'm doing a hangman game in Python. Every loop the program asks the letter or the word: #Jogo perguntarNovamente = True game_on = True while game_on: palavra_secreta = palavra() senha_list = [l for l in palavra_secreta] chances =...
asked by 17.09.2016 / 05:03
2
answers

Divide a list into n sublists

I have the following list: l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] What I need is to split this list into n sublists, in this case you can not do it manually since n is going to be dynamic.     
asked by 16.08.2016 / 23:12
1
answer

Reordering of dictionary, exchange values with keys

I have the following dictionary: tests_dict = {'test 1': ['Manuel', 'Mariana', 'Filipa'], 'test 2': ['Manuel', 'Filipa', 'Mariana'], 'test 3': ['Mariana', 'Manuel', 'Filipa']} What I need is that the keys of the new dictionary are the names...
asked by 11.12.2016 / 10:19
1
answer

How to set date formats in Django 1.7 for the whole system

Is there any way to change display settings and / or date formatting at system level?     
asked by 08.02.2015 / 17:30