Questions tagged as 'python'

3
answers

Get a part of the text

I have the following text    /department-sales-palermo-page-3.html And I need to get everything that is after the 3 script (-) The first thing I thought was doing url = /departamento-venta-palermo-pagina-3.html url[-13:] and he r...
asked by 12.12.2018 / 18:14
3
answers

Operators + = and / = with while in Python

I am starting to study Python through an online course. Although I have worked in R for a couple of years, and in general, I think the programming has many similar bases, there are notable differences. One of the most obvious ones I have...
asked by 23.08.2017 / 20:49
1
answer

Use of sleep in python [closed]

I know I need to import sleep of time : import time or from time import sleep And that applies like this: time.sleep(s) but I do not know how to include it in the rest of the code.     
asked by 06.01.2016 / 01:46
1
answer

How to move to a function for better organization in Python

Good I have several parts of code that I want to pass to functions and I need a brief explanation with an example of a portion of my code: from xlrd import open_workbook book = open_workbook("archivo.xlsx") for sheet in book.sheets(): for...
asked by 19.10.2018 / 22:32
2
answers

return True if at least one item in a list is 2 or 3

In a list of 2 integers I want True to return if it contains a 2 or a 3 with the following code: def has23(nums): for i in range(len(nums)): if nums[i] == 2 or nums[i] == 3: return True else: return False For example,...
asked by 01.10.2018 / 01:43
2
answers

How to limit decimals without rounding

I have the following code, which is responsible for limiting the number of decimals of the result a = 14567 n = "%.1f" % (a/1000)+"K") at the time of doing print() , I get as a result 14.6K, the problem is that I do not want me...
asked by 28.11.2018 / 20:06
1
answer

What is [:: - 1] in Python?

I would like to know in the following code: import sys if len(sys.argv) == 2: numero = sys.argv[1][::-1] longitud = len(numero) for i in range(longitud): print('{:0{}d}'.format(int(numero[i]) * 10 ** i, longitud)) e...
asked by 28.11.2018 / 17:41
1
answer

How to calculate the MCM in python?

I am learning is my first semester and I have the task of calculating the MCM in Python but in my code I get an error and I do not know how to fix it could someone tell me how to fix my code? A =int(input()) B =int(input()) C = B while(C!= 0)...
asked by 10.12.2016 / 23:06
2
answers

Move the bits of an int

I want to move the bits that make up a int using the operator << without the number of bits that make up the integer increasing. For example: i = 5 #101 en binario i = i << 2 print bin(i) I want the bits that make...
asked by 25.11.2017 / 00:26
4
answers

Sort lists in Python 3 depending on another list

Dear, I have several lists that depend on one another, for example in a list I have a code and in another I have the date of that code. My problem is that I had to add a new code list that still has its list of dates. My intention is to create a...
asked by 26.07.2017 / 20:55