Posts by Guilherme Santana De Souza • 743 points
28 posts
-
5
votes1
answer10433
viewsQ: What is the difference between Sorted() and . Sort()?
Why the function sorted() is considered more direct than the method .sort() used in lists with tuples?
-
3
votes1
answer736
viewsQ: You can access the key through the value:
In dictionaries, in Python, is it possible to access a key through the value? Is there any method that inverts key/value?
-
1
votes1
answer245
viewsQ: Database in Tupla
I need a code that receives data (values) and prints them according to your key. Each entry corresponds to a given of a hypothetical person, which contains Age, Name, Sex, Marital Status, Number of…
-
2
votes1
answer4199
viewsQ: How to stop a loop using the input provided by the user?
I’m writing a program that receives entries and creates a dictionary from them. I need the loop I use to insert the entries in the dictionary to be broken when the entry is "9999", but it is not…
-
2
votes4
answers16229
viewsQ: How to add entries to a dictionary?
How to add user-provided entries to a dictionary? For example: Entree: 1 abcde 2 adecd 3 aaabb The created dictionary would be: dicionario = {'abcde' : 1, 'adecd' : 2, 'aaabb' : 3} or dicionario =…
-
1
votes1
answer93
viewsA: Why does the following code not work?
I solved my problem by changing int() for float() in row 5. Code: quantidade = int(raw_input()) inicio = 0 ListaDeNotas = list() while quantidade > inicio: notas = float(raw_input()) inicio =…
-
-1
votes1
answer93
viewsQ: Why does the following code not work?
The code should receive a number of student grades, print the grade average and how many grades are 10% below and 10% above average. The code is like this: quantidade = int(raw_input()) inicio = 0…
-
1
votes1
answer5079
viewsQ: How to merge an array?
I am writing a program that merges the values of two arrays, with the same amount of values. The program receives as input amount of values in each array. It then takes the values and at the end…
-
0
votes2
answers226
viewsQ: Why does the following code print 'None' instead of the list?
The program must receive values, in a quantity specified by the user. I need a list to be created with these values. Why does this code not work? quantidade = int(raw_input()) inicio = 0 lista1 =…
-
0
votes6
answers41177
viewsA: How to find the position of an item on a list?
Another way: menor_ate_agora = None quantidade = int(raw_input()) numeros = raw_input() NumerosNaLista = numeros.split() if len(NumerosNaLista) == quantidade: for valor in NumerosNaLista: if…
-
0
votes6
answers41177
viewsA: How to find the position of an item on a list?
I got it this way: quantidade = int(raw_input()) numeros = raw_input() NumerosNaLista = numeros.split() if len(NumerosNaLista) == quantidade: MenorValor = min(NumerosNaLista) print "Menor valor:",…
-
4
votes6
answers41177
viewsQ: How to find the position of an item on a list?
I am writing a program that takes a specific amount of values, and returns the lowest value of the list and its position. It is as follows: quantidade = int(raw_input()) numeros = raw_input()…
-
3
votes1
answer854
viewsQ: How to calculate test scores?
I’m writing a code that prints a student’s grade according to the number of questions he gets right. But I need the program to do the calculation in a specific amount of times. The program must…
-
1
votes4
answers12868
viewsA: How to print multiples of N in a range?
I got it this way: N = int(raw_input()) A = int(raw_input()) B = int(raw_input()) for i in range(A, B + 1): if i % N == 0: print i if N > B: print 'INEXISTENTE' Thanks for the tips!…
-
1
votes3
answers425
viewsA: How to define a function that calculates the lowest speed?
I did it this way and it worked. Thanks for the help! Only now have I seen your answer. def velkmh(Vi, A, T): V = Vi + A * T return V vi1 = float(raw_input()) a1 = float(raw_input()) t1 =…
-
2
votes3
answers425
viewsQ: How to define a function that calculates the lowest speed?
The program must have a function that calculates the lowest speed among those calculated from the data provided. The user must provide as input, 9 values, of 3 in 3, which correspond to speed,…
-
1
votes4
answers12868
viewsQ: How to print multiples of N in a range?
The program must receive as input three values N, A, and B, and must print the multiples of N contained in the interval between A and B. I am doing it as follows, but it is going wrong: N =…
-
-4
votes1
answer804
viewsQ: Count amount of "holes" in the letters of a text
I need to write a program in Python that counts the amount of "holes" in a string. Imagine, for example, that the letters "A", "D", "O", "P", "R" have only one hole. Similarly, the letter "B" has…
-
1
votes1
answer199
viewsQ: How to provide a specific amount of strings to be tested?
I can test whether a user-provided string is a palindrome or not (word or phrase that can be read backwards by ignoring upper and lower case spaces and letters such as: Help me get on the bus in…
-
8
votes9
answers17879
viewsA: How to identify if a string is a palindrome?
I was able to solve it this way: string = raw_input() stringSemEspacos = string.replace(' ', '') stringTodaMinuscula = stringSemEspacos.lower() stringInvertida = stringTodaMinuscula[::-1] if…
-
10
votes9
answers17879
viewsQ: How to identify if a string is a palindrome?
A palindrome is a word or phrase that has the property that can be read from right to left and from left to right. For example, the strings "aaaaa", "1221", "bbaabb" are palindromes, however the…
-
6
votes6
answers37862
viewsQ: How to remove characters from a string?
The program must read two strings and remove from the first string all the letters that occur in the second string. Example: Be the strings "chocolate" and "hollow", then the program should print…
-
1
votes1
answer3034
viewsQ: Adding up positives in a range using only while
I need to write a program using loop (while) that receives two numbers as input, can be positive or negative and not necessarily in ascending order, and the program must print the sum of all…
-
0
votes1
answer211
viewsQ: Sum of numbers smaller than n that are multiples of 3 or 5
I need to write a program that receives an n number and prints the sum of all numbers smaller than n and that are multiples of 3 or 5. For this, I must use only the while repeating structure and no…
algorithmasked Guilherme Santana De Souza 743 -
2
votes3
answers5527
viewsQ: List in Python with non-repeated values without using set function?
How can I create a list from the sum of two previous without some value appearing repeated, without using the function set? Example: >>>a = [1, 2, 3] >>>b = [3, 4, 5] >>>c…
-
6
votes3
answers1779
viewsQ: How not to repeat values in a Python list?
If I create two lists, and then add the two, I create a third that owns all the items of the previous two: >>>a = [1, 2, 3] >>>b = [3, 4, 5] >>>c = a + b >>>print…
-
2
votes1
answer385
viewsQ: Multiple Python input factorial
I need to write a program in the Python language that reads multiple entries, and when receiving the "-1" input, the program prints the factorial of the respective input numbers. Detail: need to use…
pythonasked Guilherme Santana De Souza 743 -
6
votes2
answers9159
viewsQ: Read multiple numbers on the same line with raw_input
I need to write a program that reads values and then use them to calculate areas of different geometric figures. My problem is: how to enter the data on the same line? Example: 3.0 4.0 2.0 followed…
pythonasked Guilherme Santana De Souza 743