Posts by Cadu • 626 points
18 posts
-
3
votes1
answer1815
viewsQ: Differences between list, tuple and set
I know that in Python there are three structures that apparently resemble each other, but that in the background there are differences. They are: list, tuple and set. List a = [1, 2, 3, 4] Tuple a =…
-
3
votes2
answers512
viewsA: How to simplify the if command in python?
As seen in the @Wictor Chaves reply, you can use lists or tuples, but I’ll bring you one more option: sets (set). A set stores similar values to each other and, by definition, unique within the set.…
-
5
votes0
answers48
viewsQ: Use of Else outside an if
I was writing a program that would give me all prime numbers between 1 and a certain number that should be informed by the user. After several adjustments to the code, I came to the following final…
-
0
votes2
answers53
viewsQ: Library import
A while ago I had a question about importing libraries (here: Why should we import Messagebox explicitly into Tkinter even importing with the asterisk?) and explained to me that, in that particular…
-
2
votes1
answer4515
viewsQ: Python data output formatting
My question is about formatting output data from the program. I’m solving one of the exercises wiki.python.org, whose data entry is as follows:: alexandre 456123789 anderson 1245698456 antonio…
-
5
votes3
answers150
viewsQ: Two equal programs providing different outputs
I’m developing a program that’s one of those classic programming exercises that involves the Fibonacci sequence. The program is simple, it asks the user to enter a term of the sequence and the…
-
12
votes4
answers242
viewsQ: What’s behind the "go"?
Day I came across a question from a user who wanted to print a string, but with time interval between each character, so I suggested that it use the following code: from time import sleep frase =…
-
3
votes2
answers179
viewsQ: Why should we import Messagebox explicitly into Tkinter even if it matters with the asterisk?
Whenever I see programs using tkinter and messagebox see the following two lines at the beginning of the code: from tkinter import * from tkinter import messagebox If we use from tkinter import * we…
-
1
votes1
answer495
viewsA: Indexerror: list assignment index out of range
The string representing the gallows needs to have empty spaces so that it can be replaced by the hangman’s parts as the errors occur. In the code fragment below add 6 spaces in each line next to…
-
1
votes1
answer235
viewsQ: Word repetition
I’m developing an algorithm that sings the elephant’s music, I think everyone knows it. Who doesn’t, it works like this: a) For the first elephant, write in the singular. b) For the second elephant…
-
4
votes3
answers155
viewsQ: Why does print() print outputs one below the other and not the other?
Continuing my studies in Python, a new doubt arose. Before asking, I researched here on Sopt using the expression "print next to Python" and I did not find anything that could kill my doubt and…
-
3
votes3
answers6692
viewsQ: Rounding down in Python
I’m writing a program in Python and I came up with a question here. Before coming to ask I searched for "Python Rounding" here on Sopt and found two old questions with the subject, but both did not…
-
0
votes1
answer164
viewsA: Condition error of Pycharm
Days ago I had similar doubt and Anderson Woss answered me brilliantly in this post here: Difficulties with using IF. His problem is basically the same as mine. I copied his code, pasted here and…
-
0
votes3
answers387
viewsA: I created a Python function, but it is not executed
You have defined the function jokenpo() but it didn’t call, so it won’t run until it’s called. Add the following at the end of your code: if __name__ == "__main__": jokenpo() The code fragment above…
-
1
votes3
answers65
viewsQ: How to join the score with the last word on the left?
It may sound like a silly question, but I really didn’t find an answer in my readings. I created a program whose purpose is to calculate my Coefficient of Performance and the percentage of the…
-
-2
votes1
answer173
viewsQ: Difficulties with using IF
Good morning, you guys. I’m still a beginner in programming, I’m trying to write a simple program that calculates the coefficient of performance and reports the percentage of the course completed,…
-
0
votes2
answers127
viewsA: Difficulties with the FOR command in Python
I was able to solve the problem of repetition of azmt using a loop with two conditionals inside, as put below. Thank you all for your help. import turtle from math import radians, sin, cos f =…
-
0
votes2
answers127
viewsQ: Difficulties with the FOR command in Python
I’m putting together a program that reads information about angles and distances from a text file and draws according to the information contained there. The program should also calculate azimuths,…