Posts by Carlos Sanches • 179 points
6 posts
-
0
votes1
answer54
viewsQ: Python bitwise operator output
Why the value of ~True is -2 and that of ~False is -1? The logical operator equivalent not, in not True, results in False and vice versa.…
-
0
votes0
answers28
viewsQ: Mouse placement in the center of a rectangle with pygame.mouse.get_pos()
Hello! I read the following code with Pygame: import pygame PRETO = (0,0,0) AMARELO = (255,255,0) VERMELHO = (255,0,0) VERDE = (0,255,0) AZUL = (0,0,255) BRANCO = (255,255,255) LARGURAJANELA = 500…
-
0
votes0
answers24
viewsQ: String concatenation from variables in the execute method of sqlite3 in python
I am trying to insert data into a table created in Python (module sqlite3) indirectly, that is, through variables that receive the values of inputs and not directly by typing them into the string of…
-
6
votes2
answers229
viewsQ: If Python strings are immutable, how can we change them with the replace() method?
If Python strings are immutable, how can we change them with the method replace(), for example? Ex: s = "banana" s = s.replace("b", "z") print(s) # zanana Is this a change of the original string or…
-
7
votes2
answers195
viewsQ: Question about entering items in a list with indexes inside Python brackets
You can insert items into a list using methods such as, append(), extend(), or insert(). But it is also possible to insert through indexes in square brackets, normally used to replace items and not…
-
3
votes0
answers35
viewsQ: How does the Python identity operator work?
I’m starting in Python and would like to ask a question based on the code below: Case 1 x = 5 y = 5 print(x is y) # retorna True Case 2 x = "carro" y = "carro" print(x is y) # retorna True Case 3: x…