Posts by Lucas Souza • 567 points
33 posts
-
0
votes1
answer141
viewsQ: Packaging in Kotlin
I am starting my studies in Kotlin and am trying to solve the following problem: Create a class to represent a person, with private attributes of name, date of birth and height. Create the necessary…
-
0
votes1
answer82
viewsQ: What is the difference between running the program on the emulator and on a physical device?
I’m starting studies on android development with Android Studio and would like to know if it is possible to create applications just running the code on a physical device or if it is necessary to…
-
1
votes2
answers33
viewsQ: Array as a function parameter
My program stores 10 numbers in a vector and Zera the numbers that are less than 0. I am receiving these two error messages: Passing argument 1 of 'Zeranegativos' makes Pointer from integer without…
-
1
votes1
answer112
viewsQ: How to avoid repeating commands through a function?
I am creating a program to do some math math with some commands and has 1 line of code that repeats in all conditions, with only a small change in each of the conditions. My question is how to…
-
-8
votes2
answers209
viewsQ: Creation of a module
I’m having a hard time creating my own module. I would like an example with a step by step steps to create a module so I can identify where I am missing.
-
0
votes1
answer684
viewsQ: Syntax of the Lambda function
I’m right at the beginning of the Lambda function study and I’m pretty much lost. I know the code could be done only with the "sum" function but I want to learn the Lambda syntax. a = [] for b in…
-
0
votes2
answers659
viewsQ: Problem using print to show function result
I’m creating a function that scrambles and returns the typed word, but I don’t know how to use the print (if this is really the case) to show the result of the function below: def f(): a = [] x = 0…
-
0
votes1
answer779
viewsQ: Indentation in Python
I wonder where I could put blank spaces to separate parts of the code according to PEP8. q = int(input('Quantos números sua sequência tem?(3 ou mais)')) if q < 3: while True: q =…
-
-3
votes1
answer1085
viewsQ: Use of python Return
def repita(): x = 2 while n % x != 0: x += 1 repeat() while n > 1: n = n / x #aqui se encontra o primeiro problema, já que "n" não é reconhecido fora da função x += 1 if n % x != 0:#mesmo…
-
1
votes3
answers2240
viewsQ: Python libraries to check if a number is prime
Is there any library to determine whether the number is prime or the only way is to create the program and run it normally?
-
1
votes1
answer2225
viewsQ: How to check if one list is inside the other?
My code: n = [int(input()) for c in range(0, 5)] lista = list(range(0, 10)) if n not in lista: print('1') else: print('2') Digit 1, 2, 3, 4, 5 and the answer is "1", and the numbers from 1 to 5 are…
pythonasked Lucas Souza 567 -
2
votes1
answer76
viewsQ: Variable creation
How do I create a variable and add the type as integer, but without having any value set? I need this variable to do this: a = int(input()) b = int(input()) x = int # tentei colocar o tipo da…
-
-3
votes1
answer599
viewsQ: How to change the value of variables every time you repeat the def function?
My algorithm solves the following problem: Create an algorithm that reads 4 typed values and indicates if any pair of numbers sums 8 or a number greater than 8. s = [int(input()) for c in range(4)]…
python-3.xasked Lucas Souza 567 -
11
votes1
answer2259
viewsQ: What to use to format a string, % or format?
Use "%" or ".format"? I think the last one is newer, but there is some other aspect to be taken into account when deciding which one to use?
pythonasked Lucas Souza 567 -
1
votes1
answer70
viewsQ: Problems with using Return
My code: def a(): print(1 + 1) n = input() print(2) I don’t know how to return only the "n" out of the function to use it with an "if". Ex.: if n in ...…
python-3.xasked Lucas Souza 567 -
1
votes2
answers5286
viewsQ: Put the input data into a list
I need to store the 10 numbers typed by the user in a list, only using "for". for c in range(0, 10): s = int(input()) Then I would just need to know how I store each number after being typed and not…
python-3.xasked Lucas Souza 567 -
2
votes2
answers394
viewsQ: Meaning of these nomenclatures in Python and other languages, if the names are universal
I would like to know the meaning with examples, if necessary, of the following names: Class Object Attribute Method
-
0
votes1
answer663
viewsQ: Login information validation does not work
Doubts are throughout the program import string alphabet = list(string.ascii_lowercase) n = range(0, 10) name = input('Digite seu nome de usuário:') if name in n: while True: print('Apenas letras…
-
-1
votes1
answer1399
viewsQ: Return an input that is inside a function
I have that code: bebidas = {'Suco de laranja': 5.99, 'Suco de uva': 5.99, 'Suco de açaí': 5.99, 'Coca Cola(lata)': 6.50, 'Vitamina': 7.50} salgados = {'Coxinha': 5.00, 'Pastel': 7.50, 'Hamburguer':…
python-3.xasked Lucas Souza 567 -
0
votes1
answer31
viewsQ: How to differentiate 2 inputs created with for loop and perform operations between them
How do I sum the 2 values typed by the user? My code: for c in range(0, 2): n = int(input('Digite um valor:')) How to differentiate the first value of the second to do operations as sum and…
pythonasked Lucas Souza 567 -
0
votes0
answers34
viewsQ: Make a code executable
It is possible to make an executable code without downloading anything and being done in an online IDE?
python-3.xasked Lucas Souza 567 -
2
votes2
answers1647
viewsQ: Use of def function
I would like to create a function def to the first input and then return it in the third line. Example: def se(): sex = input('Digite seu sexo:') while sex != 'M' and sex != 'F': #não sei como se…
-
1
votes1
answer647
viewsQ: Problems with the While Repetition Structure
I’m trying to create a program based on the repetition structure while, but the loop does not end. sexo = str(input('Digite seu sexo:')) if sexo != 'M' or sexo != 'F': while sexo != 'M' or sexo !=…
-
-2
votes1
answer25847
viewsQ: Command to finish the program
Is there a command to finish the program in Python or can only finish using ways like this: print()
-
7
votes3
answers1500
viewsQ: When to use blank lines in a Python program?
Skipping lines is one of the aspects that make a program well indented? If so, what is the criteria used to skip lines?
-
1
votes1
answer4647
viewsQ: How to manipulate strings with ". find"
I can use ". find" to make the program search for a word within a typed text and say whether it exists or not?(true or false) and what line of text is located, if not, what command do I use to do…
-
0
votes2
answers787
viewsQ: How to add up several numbers that were typed in the output?
What I got so far: for c in range(3): n = int(input()) n += n #tenho quase certeza que essa parte não está certa print(n) How to add up several numbers that were typed in output?…
pythonasked Lucas Souza 567 -
-4
votes2
answers3074
viewsQ: How to calculate numbers in a given range?
How could I compute the sum of the numbers in a range of 1 to 500 in which the summed numbers of that range should be odd and multiple of three? I only managed to take the break so far: for c in…
-
-4
votes2
answers824
viewsQ: How do I make the program show all the combinations and then the number of combinations that were formed?
What I’ve got so far: from itertools import permutations word = str(input()) for subset in permutations(word,len(word)): print(subset)
pythonasked Lucas Souza 567 -
1
votes2
answers52
viewsQ: How to play a list that skips the numbers according to the number typed
Preferably something that explains the answer below (without the spaces) 0 1 4 9 16
python-3.xasked Lucas Souza 567 -
0
votes1
answer57
viewsQ: Problem to show the value in the dictionary that corresponds to the user’s response
bebidas = {'Suco de laranja': 5.99, 'Suco de uva': 5.99, 'Suco de açaí': 5.99, 'Coca Cola(lata)': 6.50, 'Vitamina': 7.50 } simounão = int(input('Olá, gostaria de ver nosso…
-
4
votes1
answer564
viewsQ: Is there any way to delete the auto space that appears after the python comma?
A brief example: zero = 0 print('exemplo',zero) The program shows: example 0 I wish without the space: exemplo0…
python-3.xasked Lucas Souza 567 -
2
votes1
answer1263
viewsQ: Create python dictionaries using lists
I’m trying to create a translator that translates Portuguese words into binary code. I was able to do this to type only one word, but when I try to use 2 words, in the case "ab", nothing happens. I…