Questions tagged as 'python'

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
2
answers

problems list in python

I'm trying to solve this problem in python: Make a program that loads a list with the five car models (example of models: FUSCA, GOL, VECTRA etc). Charge another list with the consumption of these cars, that is, how many miles each of these c...
asked by 11.01.2018 / 11:19
1
answer

How to go back days in datetime, python?

I need to return a string in the format "dd / mm / yyyy" in python, I got through the datetime library. import datetime date = datetime.datetime.now().strftime("%d/%m/%y") But I also need the date 7 days ago, a week earlier.     
asked by 02.01.2018 / 13:14
2
answers

Libraries in python to check if a number is prime

Is there a library to determine whether the number is prime or the only way is to create the program and run it normally?     
asked by 23.12.2017 / 22:10
1
answer

Bugging shortcuts with python

I need for my project, some function using Python 2.7 to enter a URL, and get the next URL from it. - > Example: goo.gl/LAKFXG = link bit.ly/2D3SEnZ = link I do not want to use the API of these URLs, but something that actually enter...
asked by 19.12.2017 / 16:48
1
answer

How to transform a diagonal elements list from a python array [closed]

I have the following array, for example: 1 2 3 4 5 6 7 8 9 3 8 9 matriz = 4 5 2 3 4 4 2 3 4 5 3 6 4 5 3 4 5 6 I would like to get only the elements of the main diagonal, such as: A = [1, 8, 2, 5, 5]   ...
asked by 07.12.2017 / 13:08
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

Counter in python

Well I'm doing a screenshot program but I want it to replace in the file name when saving, the characters "XX", by the print number. Ex: ScreenShotXX.jpg in "XX" I want to put the print number ex: 01, 02 Code used: import pyscreenshot as Image...
asked by 11.02.2017 / 15:16
1
answer

I need to use an array that is in one code in another!

I have a project with the following files: old     play.py     impressao.py I need to use a 3x3 array that is in the game.py in the script.py impressao.py #função de impressão def impressao(): print(" Coluna 1 Co...
asked by 14.06.2017 / 03:45
1
answer

Import Python DLL in C ++

How do I compile a Python class into a DLL so I can import it into C ++, using Python features that are not available in C ++? I want to be able to import it without having Python installed on the computer     
asked by 24.09.2017 / 03:35