Questions tagged as 'python-2.7'

2
answers

Problem with syntax error in else python

I'm having a problem with this code in Python where, when I try to run, it informs me that syntax error exists in a else . Here is the code and error below: n=int(raw_input('')) i=0 for i in xrange(0,n): num_poco=int(raw_input('')) ti...
asked by 26.09.2017 / 01:57
3
answers

code to return divisors and compare common ones

I am trying to create a code that returns me the common divisors between 2 variables that receive integers. And then show the common divisors. To return the divisors I am using this code to test: import numpy as np def divisores(num): n =...
asked by 18.03.2018 / 23:02
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
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
2
answers

XHR in javascript for Python displays three times the return [closed]

Recently I deployed Python on my IIS server, and started testing some requests. First I created the javascript code, as you can see below: sendRequest = function() { var http = new XMLHttpRequest(); http.onreadystatechange...
asked by 10.03.2017 / 23:19
2
answers

Multiple of 10 closest to one sum

def multiplo(x): somamulti= somaImpares(x) + somaPares(x) if somamulti/10==0: return somamulti/10 else: return In this function I did what happens is as follows: somamulti adds 2 values, in this case it can...
asked by 17.03.2015 / 22:52
1
answer

How to assign the elements of a list to different variables in Python?

I have a list, like the following: lista = [1, 2, 3, 4, 5] Even though I do not know how many elements are in the list, how do I assign each element of the list to a different variable? (as in the example below) elemen1 = '1' elemen2 = '2...
asked by 28.11.2018 / 14:30
3
answers

Determine the indices of a vector that must be subtracted

I have the following vector: a = [10, 20, 30, 40, 50, 60...] I need to create a new list that is subtracting the previous index from the previous one. For example: b = [indice[0] - indice[1], indice[2] - indice[3], indice[4] - indice[5].....
asked by 18.08.2017 / 04:35
2
answers

How to make a nested FOR?

I'm opening two files, one is a text, and the other is a list. I'm wanting through for nested to check how many times each list item appears in the text. I did so: arquivo = open('texto.txt', 'r') lista = open('lista.txt', 'r') for item in...
asked by 22.08.2017 / 21:58
1
answer

Skip certain indices in a Python list

I have the following situation: I have a list of 64 items and I want the first two values to appear and all the others after 2. An example would be: lista = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22] I want the values...
asked by 08.03.2017 / 00:41