-1
Good afternoon! I’m a beginner and I’m trying to learn python, I tried to make a program that calculated if the number typed is prime and then the program asks if I would like to calculate all the primes before it put when it arrives in the while loop it keeps repeating forever regardless of the answer I give
I would also like to ask for tips on courses/books, preferably free or very cheap, so that I can learn more.
numero=int(input('Digite um numero: ')) div = 0 for x in range (1,numero+1):
resto = numero % x
if resto == 0:
div += 1 if div == 2:
print('{} é um numero primo.'.format(numero)) else:
print('{} nao é um numero primo.'.format(numero)) escolha='a' escolha = input('deseja saber quais os numeros primos até {}? y=Sim / n=Não: '.format(numero)) while escolha != 'y' or escolha != 'n':
escolha = input('Digite uma opcao valida. y=Sim / n=Não: '.format(numero)) if escolha == 'y':
for num in range(numero+1):
div=0
for x in range(1,num+1):
resto = num % x
if resto == 0:
div+=1
if div==2:
print(num) else:
print('Até mais!!!')
Since you are asking for course tips, I recommend edx.org.here. It’s given by Microsoft, and it’s free. I started "from scratch" by this then there’s another one a little more advanced but still for beginners. If you want a course certificate you have to pay, see if the content fits what you are looking for :D
– André Portugal
I’ll take a look, thanks for the :D indication
– Leonardo Machado