Good morning, guys. I am still new to programming, I am trying to write a simple program, which calculates the coefficient of performance and report the percentage of the finished course, but I am having problems with an if conditional that is n...
def mod_2to32sub1(x):
s = 0 # the sum
while x > 0: # get the digits
s += x & (2**32-1)
x >>= 32
if s > 2**32-1:
return mod_2to32sub1(s)
elif s == 2**32-1:
return 0
else:...
famous_person = "Dalai Lama disse:\n"
message = "\Se quer viver uma vida feliz, amarre-se a uma meta, não a pessoas nem a coisas\"
print(famous_person + message)
I have tried everything (including putting two quotes). If I put two quotes to...
I am declaring an X variable with the value of another Y using = , but when having a append in the variable X >, Y also changes.
Code:
'''
Resultado obtido:
['casaRJ', 'casaSP', 'casaDF', 'apRJ', 'apSP']...
I was trying to run a very simple program through the terminal (use ubuntu gnome):
#encoding: utf-8
y = int(input("Ultimo número: "))
x=0
while x <= y
if x % 2 == 0
print (x)
x=x+1
and I came across the following error:
File...
For example, you give the number 100 and the largest prime number within 100 is 97. How can I program this?
"Write the largest_primo function that receives an integer greater than or equal to 2 as a parameter and returns the largest prime num...
How do I compare elements of 2 lists, and return the quantity of elements in common?
For example:
a=[1, 2, 3, 4, 5]
b=[6, 7, 8, 9, 10, 1, 2, 11, 22]
This should return 2, because there are only 2 elements in common.
It is the following I have an input file (.txt) which is as follows:
9
branco
preto
azul
verde
rosa
amarelo
vermelho
cinza
lilas
OHLEMREVU
BBRANCOZA
SRAMSUPAO
AABAPOTZZ
LNZROERNU
IUIEPDOII
LOLLORACA
ITMOTERPP
LIEAZVYUU
and from this I want...
Could you give a help with Array in python ?!
The exercise is as follows, a matriz_mult(n1, n2) function receives two arrays as a parameter and returns True if the arrays are multiplied in the given order and False otherwise...
def somentenumeros(entrada):
try:
int(entrada)
return True
except:
return False
while True:
cpf = input('Digite seu CPF ou digite os nove primeiros digitos ')
if somentenumeros(cpf) == False or len(cpf)!=...