Questions tagged as 'python-2.7'

1
answer

Find complete words in a string that may or may not be surrounded by "_"

I'm passing two lists for a class DictionaryMaker() . This will generate a match between words of the item of one list with the item of the other, in order to declare each item as a key and value. The class and the method work for me, b...
asked by 28.06.2017 / 16:54
3
answers

How to create a List of setters and getters in python?

This is how it looks in java, I have to pass it to python and I have no idea how to do it. public List<Archivo> getArchivos() { return archivos; } public void setArchivos(List<Archivo> archivos) { this.a...
asked by 08.09.2017 / 14:00
1
answer

I do not understand how Or works in python I refer to the following code

Someone can help me because and how it works in python because I try to do it according to the documentation and it gives me different results import operator operator.or_(2,8) 10 operator.or_(8,2) 10 8 | 2 10 2 | 8 10 2 or 8 2 2 | 8 10...
asked by 04.01.2019 / 15:04
2
answers

How to know in Python if the elements in a list are different?

I want to know how I can do to verify that the elements of a list are all different (none repeated). Ex: lista=[1,-1,1,3,9,5] codigo_verificador() Exit: True # Hay un elemento repetido How can I know that there are repeated elements...
asked by 13.10.2018 / 01:02
2
answers

How to enter a date by keyboard and use it in Python?

I have a query, I did the exercise in C but I do not know how to pass it to Python, especially with the subject of when I enter the full date .. Here is the code in C #include <stdio.h> main(){ int DiaN, MesN, AnioN; int DiaH, MesH, An...
asked by 22.09.2018 / 00:51
2
answers

Delete occurrences in a text

I have to delete from "a las.. " to leave only the date, in Python. 21-MARZO-2017 A LAS 1600 HRS 31-ENERO A LAS 1300 HRS. 30-ENERO-2017 A LAS 1600 HRS. 20/02/2017 A LAS 1200 HORAS (MEDIODíA) 17-FEBRERO A LAS 1200 HRS (MEDIODíA) 18-NOVIE...
asked by 14.02.2017 / 16:35
2
answers

Problem with backpack problem

I am working with a case of a client in which he applies the algorithm Problem of the backpack . I am using the code that I attached, it works more or less and has errors. The example has 12 packages of different weights (which in their tota...
asked by 27.02.2016 / 03:44
2
answers

How to generate a csv file from a list?

Hello, I have the following list l=[[1,2,3,4],[5,6,7,8]] and I want to generate a csv file something like this: 1 5 2 6 3 7 4 8 the code that I have worked on is this with open("output.csv", "wb") as f: writer = csv.writer(f) w...
asked by 02.06.2016 / 15:40
1
answer

Problem with self-calculated fields in a table

I have this table: db.define_table('cotizaciones', Field('numero_ticket', 'reference tickets'), Field('numero_cotizacion', 'string'), Field('fecha_registro_cotizacion', 'date', default=now),...
asked by 28.01.2016 / 17:35
2
answers

Attempt of Eratosthenes sieve in python

Hi, I'm trying to make a code using the Eratosthenes Screen method but I get confused in the part of multiplying and eliminating the number that is not prime, the teacher says we should use a del or something to eliminate the number what is in t...
asked by 19.10.2018 / 03:32