Questions tagged as 'for'

2
answers

"for" with step "float": TypeError: 'float' object can not be interpreted as an integer

I want to loop from 0 to 100 with step 0.1: for x in range(0, 100, 0.1): a = cos(radians(x)) But I get this error:    TypeError: 'float' object can not be interpreted as an integer How can I loop through step float?     
asked by 08.10.2018 / 20:06
2
answers

PHP - shuffle array

I'm scheduling a news feed page in PHP . I ask your help to help me shuffle the $tagsArray array so that the posts are not always in the same order. Thank you in advance! Code: <?php $conexao = mysqli_connect("localho...
asked by 19.02.2018 / 22:21
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

Problem in the algorithm on percentage

I had to do this algorithm:    In 2010, a small Brazilian city has 20,000 inhabitants. The forecast   of IBGE is that this city grows at a rate of 5% per year. Knowing   addition, make an algorithm that prints on the screen the year and popul...
asked by 30.01.2018 / 00:06
2
answers

Rule of For in C

I have a doubt about the for loop, that is, I have a for statement and I have to get the result that the machine gave. I have this: for(x=2,Y=1;X < 11;x++)y+=x++ I know that the variable X starts at 2 and Y at 1. I know that while X is l...
asked by 21.02.2016 / 20:20
3
answers

C - how to calculate the factorial of a number? [duplicate]

To try but I can not, for example: the factorial of 5 is given by 5 * 4 * 3 * 2 * 1. You have to develop a program that calculates the factorial of a given number as input. (using for)     
asked by 26.01.2018 / 18:33
1
answer

Tie is from index 1 array java

I have a function that makes a for loop in a String array. I need the loop to start from index[1] of that array. But I'm not getting it. String arquivo[] = arquivoDecodificado.split("\r\n|\r|\n"); for(String linha: arquivo ) {...
asked by 12.06.2018 / 15:22
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
3
answers

Array in PHP that is not getting values

The purpose of the exercise was to create an array of 20 numbers ranging from -100 to 100. I have to distinguish between negative and positive values. If it is positive I have to add the value in its entirety to a variable and if they are negati...
asked by 24.10.2017 / 17:34
4
answers

Repeat to call variables

I have four variables [t1, t2, t3, t4], and each of them has been defined as a string before. t1 = 'A vida vai ficando cada vez mais dura perto do topo.' t2 = 'A moralidade é a melhor de todas as regras para orientar a humanidade.' t3 = 'Aquil...
asked by 02.04.2018 / 00:12