Posts by Solkarped • 2,428 points
218 posts
-
1
votes2
answers72
viewsA: Accept entry with only 1 digit
When we want to restrict the number numbers to just "1" digit, we realize that we want numbers that only belong to the set [-9, 9], that is to say... numeros = [-9, -8, -7, -6 , -5, -4, -3, -2, -1,…
-
0
votes3
answers1958
viewsA: How to print list elements in reverse order?
To resolve this issue we must assemble 2 repeat loops. One to assemble the list and one to read and display the list values in reverse order. Well, to resolve this issue we can use the following…
-
1
votes2
answers128
viewsA: How to display a list always sorted as new items are inserted
Note that in this issue you will have to implement a laço de repetição. Regardless of the loop you use, you will need a "flag" stop. This flag will stop typing possible subsequent values. Because,…
-
0
votes2
answers2087
viewsA: How to draw numbers from a list, randomly and without repetitions?
To resolve this issue we can use the following code: from random import sample def sorteio_sem_repeticoes(): return sorted(sample(range(1, 16), 9)) print(sorteio_sem_repeticoes()) Note that the…
-
0
votes4
answers2686
viewsA: Create multiple lists containing random numbers
On this issue it became clear number of lists, which in this case is 50, was also clear the amount of elements, which in this case is 12, however, no mention was made of crease of which you wish to…
-
1
votes4
answers1030
viewsA: Sum the n odd terms ,using Loop for ,without using list, allowed functions:input,int,print and range
In this matter you have to pay attention to two things. First thing: Define an accumulating variable (variable that will store the calculation performed in each iteration of "for"). Variable that I…
-
0
votes2
answers205
viewsA: Store read names in a list and randomly choose one of them
The problem with your code is that you esqueceu to create the list. One of the right ways to solve this problem is by using the algorithm I implemented, right below. from random import choice #…
-
1
votes2
answers224
viewsA: Help in college exercise
In this issue you have to pay attention in two situations: 1º verify the resto da divisão between the debt and the maximum value of the tranche and 2º verify the total of plots. Note that, in some…
-
1
votes3
answers8207
viewsA: Separate each phrase word in an index from the python list
On this issue just go to phrase as parameter of the list. For this we should simply implement the following code below... frase_inteira = list(input('Digite a frase: ').split()) print(frase_inteira)…
-
2
votes3
answers1885
viewsA: Longest word in a sentence in the list - Python
To solve this question we can use the following logic: Capture any sentence and add it to a list; Scroll through this list and capture the size of each word; Insert the size of each word in another…
-
1
votes2
answers5930
viewsA: List input
What we must do in this matter is proibir the insertion of any element, the value of which corresponds to the value of any other element which já exista na lista. For this I implemented the…
-
0
votes2
answers671
viewsA: Errors in the program to sort a triangle
You can use the code below. This code will receive the measurements of the three sides of the triangle in the same line separated by only one space, then the program will check if the measures of…
-
0
votes3
answers871
viewsA: How to separate characters from a string to a Python list?
It is possible to convert a string into a list. To do this, simply pass the string as a list parameter. The code below takes any string and converts it into a list. a = list(input('Digite uma…
-
0
votes3
answers95
viewsA: Difference between creating a list with each iteration and using a list comprehension
If you just want to calculate the distance between two points, you can use the following algorithm... from math import sqrt p = list(map(int, input('Digite as coordenadas dos pontos: ').split()))…
-
0
votes2
answers3029
viewsA: Python: print(...{}' .format) or print(...+str(...))
In the first case, the following operations are performed. 1º Captures a value in the "string" type. 2º Converts the captured value to "integer", inserts it in the formula, performs the calculation…
-
3
votes3
answers1292
viewsA: How to loop 'for' in 1 line?
If really necessary, yes to implement not only "1" only "for", but also "2" or "3" in one line only. For this we must use the concepts of List Comprehesions. If the structure does not need to be…
-
2
votes5
answers427
viewsA: How to run faster a code that calculates the number of factorial digits of a number?
This question refers to the number problem "3096", whose title is "overflow", made available by URI Online Judge (online programming marathon). See here the entirety of the statement. The question…
-
2
votes1
answer989
viewsQ: How to quickly calculate the sum of dividers in Python?
I would like to know how to quickly calculate the sum of the divisors of a natural number n, where 2 <= n < 109. For small numbers, I perform this operation quietly with the following code: n…