Posts by Solkarped • 2,428 points
218 posts
-
1
votes2
answers516
viewsA: Remove items from one list that are in another
From what I understand of your statement, you need to find the values that are comuns to both lists. If what matters is valor of the element, without taking into account the quantidade of…
-
0
votes4
answers11441
viewsA: A list to receive 20 whole numbers and store in a list and print the largest element in the list
We can resolve this issue in this way: maior = max([x for x in input('Digite os valores: ').split()]) print(f'O maior número da lista é: {maior}') When we executed this code we received the…
-
0
votes11
answers38715
viewsA: How to check if the variable string value is number?
Another interesting way to resolve this issue is by using Assignment Expressions, approached by PEP 572. With this technique the code would be: while not (n := input('Valor entre 0 e 10:…
-
0
votes3
answers11136
viewsA: Store data inside a Python loop array
To store the values within a vector, you can use the while or the for. Below, I display a way to resolve this issue using the repeat loop for: # Capturando e tratando a quantidade de estudantes:…
-
0
votes2
answers30328
viewsA: How to run a . py program by python IDLE on Windows?
With the screen of IDLE open you must perform the following steps: Click on the menu File; Click on the option Open; Navigate to the folder where your script file is (meu_file.py); Select the file;…
-
0
votes4
answers1471
viewsA: Generate random numbers and add them up
If you wish only somar the numbers that were generated randomly, you can use the following algorithm... from random import randint n = int(input('Desejas gerar quantos números aleatórios? '))…
-
1
votes4
answers669
viewsA: How to access indexes backwards within a list?
At the beginning of the question, we were given a lista, call for notas, that is to say... notas = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] This list is nothing more than…
-
0
votes2
answers787
viewsA: How to add up several numbers that were typed in the output?
You can use the following code... valores = list(map(int, input('Digite todos os valores: ').split())) print(f'\033[32mA soma dos valores digitados é: {sum(valores)}') See how this code works on…
-
0
votes3
answers325
viewsA: Occurrence of a digit on an integer using Python
To resolve this question correctly we must pay attention to two important things in the statement. The possible values of n (n > 0); The possible values of d (0 <= d <= 9). Another thing is…
-
1
votes3
answers1578
viewsA: Separating numbers into even and odd lists - Python
To resolve this issue you must implement an algorithm that monte a list of all values digitados by the user, then separe the values ímpares of pares and subsequently display them on separate lists.…
-
3
votes4
answers16556
viewsA: Generate random numbers in Python without repeating
For you to draw 4 values within the range [0, 100], without repetitions, you need to implement the range(0, 101), using the method sample library Random. Then the code can be assembled as follows:…
-
0
votes2
answers1536
viewsA: function to return the integer number
To use the functions of the methods floor and ceil, you have to first import the methods. Another thing, when we work with funções we should know how implementa-las. Note below the solution of the…
-
0
votes2
answers431
viewsA: I’m trying to write a program that calculates the monthly percentage of a distributor
Imagine you have to calculate monthly these values. In this case, you have to implement the function input() to receive these values each month that needs. Another thing the calculation of…
-
0
votes2
answers390
viewsA: Receive an integer number in the input, calculate and print the sum of the odd digits of this number in the output
In this question you can use the following algorithm... n = input() soma = 0 for c in n: x = int(c) if x % 2 != 0: soma += x print(soma) See how the algorithm works on repl it.. Note that in this…
-
0
votes6
answers7088
viewsA: Intersection between two sets (element that is in set A and B at the same time)
To find the interseção of any dois sets we can use the following algorithm... def intersecao(conjuntoA, conjuntoB): inter = list(conjuntoA & conjuntoB) inter.sort() print(f'\033[32mA interseção…
-
0
votes5
answers7921
viewsA: How to properly format CPF in Python?
If you wish to use f-String to format the output of CPF, can use the following algorithm... cpf = input('Digite o CPF: ') if len(cpf) < 11: cpf = cpf.zfill(11)…
-
0
votes4
answers846
viewsA: How to find numbers larger than X in a list
If you intend apenas know the quantidade of values greater than a given value, which in this case is 2, you can implement a repeat loop and check the sum of all numbers larger than 2. For this you…
-
1
votes2
answers177
viewsA: Printing of Matrices in Python
For you to work with matrices you must take into account the number of linhas and of colunas of that matrix. In this case you will need to specify the número de linhas and also the número de…
-
0
votes2
answers507
viewsA: How to Improve Maximum Common Divisor Algorithm - URI 1028
This question refers to the number problem "1028", whose title is "Figurines", made available by "Uri Online Judge" (online programming marathon). See here the entirety of the statement. One of the…
-
0
votes2
answers129
viewsA: PYTHON formatting
This question refers to the number problem "1435", whose title is "Matriz Quadrada I", made available by "Uri Online Judge" (Online Programming Marathon). See here the entirety of the statement. To…
-
0
votes1
answer940
viewsA: (IJ sequence 4) Why is my Python code giving Runtime error in the URI Online Judge?
This question refers to the number problem "1098", whose title is "Sequence IJ 4", made available by Uri Online Judge (Online Programming Marathon). See here the entirety of the statement. In this…
-
0
votes3
answers1084
viewsA: Python Online Library of Justice
This issue relates to the number problem "1070", whose title is "Six Odd Numbers" made available by "Uri Online Judge" (Online Programming Marathon). See here the entirety of the statement. In this…
-
0
votes2
answers319
viewsA: Python URI error - 2588 - Palindromes
To resolve this issue you can implement the following code below... import sys def main(): for line in sys.stdin: oc = [0] * 26 for char in line[:-1]: oc[ord(char) - ord('a')] += 1 ans = 0 chance =…
-
0
votes2
answers1691
viewsA: Algorithm to determine prime numbers between 2 and N. What is wrong?
To succeed in this issue you need to implement an algorithm containing two funções. A function to check whether a dado número is cousin; Another function to display numbers that are primos. to solve…
-
0
votes3
answers2297
viewsA: Python 3 make the program find out how much of a given digit is in a string or a number
One of the ways to resolve this issue is by using List Comprehensions. For this you can use the following logic: Define a variable in which the captured string will be stored; Define a variable in…
-
0
votes2
answers68
viewsA: Exercise list ordering
To remove the repeated values and sort the list you citou in the example, you can use the following algorithm... numeros = [7, 3, 33, 12, 3, 3, 3, 7, 12, 100] resultado = list() for c in numeros: if…
-
0
votes2
answers3158
viewsA: Write a python script that reads an 8-digit integer
Another way to resolve this issue is by using the function concepts along with the repetition loop for. One of the ways we can implement the code is: def soma_digitos(n): if len(n) == 8: return…
-
0
votes2
answers487
viewsA: how can I make a simple python Russian roulette
Look, just below, my version of Roleta Russa, using the loop of repetition for. # Jogo roleta russa from time import sleep from random import choice print('=' * 30) print(f'\033[34m{f"Roleta…
-
0
votes4
answers4581
viewsA: How to multiply in Python without the multiplication operator?
This question brings to light the very definition of multiplicação. What is multiplication? Multiplication is nothing more than soma of parcelas iguais. Example 1: How much 2 x 4? (2 * 4) == 4 + 4…
-
0
votes3
answers1806
viewsA: Add the first "n" elements of a Python geometric progression
If you intend to calculate the sum of the terms of a progressão geométrica you have to take into consideration two things: The general formula for calculating the sum of the terms of Progressão…
-
0
votes2
answers2303
viewsA: Random Choice in python
From what I understand, you wish implementar a programme which manages each of the tabuadas randomly. To develop this algorithm, you will need to carry out the draw with the method choice class…
-
0
votes3
answers783
viewsA: How to input() stop after space instead of line break in Python3
From what I understand, you wish capturar all the valores typed in a single line. That is, you would like to implement a program that solicitar the typing of the values, the user was able to…
-
1
votes2
answers684
viewsA: How to detect line breaking in Python input?
You can passar each of the values as elements of a given lista. In this case you can use the following algorithm... valores = list(map(int, input('Digite os valores: ').split())) print(valores) See…
-
1
votes3
answers1537
viewsA: Calculate the age group of 10 people within a repeat loop?
To solve this issue just implement a laço de repetição and, contar to quantidade de pessoas satisfying cada uma age group. For this, you can use the following algorithm... # Capturando e tratando a…
-
0
votes6
answers444
viewsA: Counting multiples of an integer is giving very different values than expected
From what I understand, you intend to contar the amount of múltiplos of a certain value that lies within a range in which the menor value is n1 and the maior value is n2. To solve this question, you…
-
0
votes2
answers103
viewsA: Negative print, it only prints the postives
From what I understand of your statement, you need to create a program that leia a number inteiro and display it. E, in case the number is negativo, also shows it, porém, Close the program right…
-
0
votes3
answers6692
viewsA: Rounding down in Python
What you’re trying to figure out is chão of a number. The chão of a number real (floating point number) is the maior integer menor that that paragraph real. Example 01: The chão of 22.6 is 22 Yeah,…
-
1
votes5
answers6310
viewsA: How to stop the end='' command in Python
For you to resolve this issue, one of the ways I suggest is to add a print vazio,that is to say, "print()" before your last print. The algorithm would look like this... tabela = ('Palmeiras',…
-
0
votes4
answers2332
viewsA: Print String vertically in Python
To resolve this issue, simply implement the following code... palavra = input('Digite uma palavra: ') for c in palavra: print(c)
-
0
votes3
answers2069
viewsA: Calculate the arithmetic mean of the integers between 15 (inclusive) and 100 (inclusive)
To média aritmética of a sequence of values corresponds to the quociente between the soma dos valores and the quantidade dos valores. In other words, the arithmetic mean is the result of the…
-
0
votes4
answers2298
viewsA: Printing a number odd sequence on a list
To resolve this issue you can use List Comprehension. This way, we can implement a code with only 1 line of code. In this case the code would be: print([c for c in range(1, int(input('Digite um…
-
0
votes2
answers264
viewsA: How to round decimal numbers to the largest integer? python
What you’re trying to figure out is, nothing more, nothing less than the teto of a number. The teto of a number real (which may be a floating point number) is the menor number inteiro greater than…
-
0
votes2
answers1757
viewsA: Request whole numbers and count even and odd numbers
From what I understand, you need to implement a program that receives 5 numbers inteiros and then, exiba the amount of values pares and ímpares that were typed. Well, the correct algorithm is just…
-
1
votes2
answers1434
viewsA: How to make the user return the specified condition when the same type wrong?
From what I understand, you want to implement a program that monte a list of numbers inteiros without repetições and, in the end, display them in order crescente. Well, the code below does tudo…
-
0
votes2
answers1349
viewsA: Record runtime in python
From what I understand, you’re wanting calcular the time of execução of the program. In order for this question to have a more obvious answer, let’s assume that we are wanting calcular the execution…
-
2
votes3
answers557
viewsA: Continue loop if input is’S'
What you want can be solved using the following algritmo: while True: print('Você está continuando!') # Capturando e avaliando a resposta. resp = input('Desejas continuar? [S/N]').upper() while…
-
0
votes2
answers59
viewsA: "print()" does not display the elements of the inserted list
As has already been answered anteriormente you are initiating the list within the loop for. In this way, every iteration of the for list elements are overwritten. Correct is you implement the list…
-
0
votes3
answers2047
viewsA: average of values typed in python input
From your statement, I understand that you want to implement a program that solicita a value inteiro, positivo and menor que 20 and then must return: The maior value between "1" and "n"; The menor…
-
1
votes3
answers2911
viewsA: How to assign 3 values to 3 variables in only one python input line?
Several are the forms we have in the Python for capture various values from a single input(). Well, to catch all 3 values to use in your code we can use the following command line: a, b, c = [int(x)…
-
0
votes2
answers141
viewsA: Problem in Python3
From what I understand, you intend to develop a program for "contar" the number of votes of each of the candidatos. One of the simplest ways to solve this question is by using the following…