19 Answers
New Answern = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0 print("Learn") else: print(x) The input is automatically 15, and the output is: 1 Solo Learn 7 SoloLearn 11 13 If 0 stands for False, why does it print "Solo", "Learn", and "SoloLearn"? Am I missing something very simple?
1/20/2021 10:18:32 PM
Albanianz19 Answers
New Answer#TRY THIS ONE n = int(input()) for x in range(1, n): if x % 2 ==0: continue if x % 15 ==0: print ("SoloLearn") if x % 3==0: print ("Solo") if x % 5==0: print ("Learn") else: print (x) AND LET ME KNOW WHAT'S YOUR ANS BEFORE PLZ
Abhay so it compares the remainder of x%3 with 0, the remainder of 15%3 (x%3) is 0 so 0 == 0 equals true. Thank youu very much, I followed you
Yes,15%3 means 15 divided 3 with remainder being 0 ,just to clear as I got confused why you used x%3 in bracket.
Yes False do equates to 0 or vice-versa(maybe) but 0 here stands for an actual integer, if you divide a number say 3 by 3 , you get remainder as 0 . So in this piece of code x%3 == 0 , where % operator returns remainder, if you have 3%3==0 , it will result in True.
Albanianz I can't explain in a more simple way than this. Do you know what remainder means? suppose x is 3 , so 3%3 will result in 0 and expression ( 0==0 ) will result in True as "==" operator checks if value on both sides are equal.
Btw do you know the code line to make the program automatically chose a number between 1-1000? Its something with randint() but I haven't learned it yet and I want to make a number guessing game but I don't understand it
Thanks I had already solved the project but wondered why it was "0" and got the answer from Abhay
https://www.sololearn.com/coach/612?ref=app this is the correct fizz buzz program u can try this Albanianz
n=int(input()) for i in range(1,n+1): if i%5==0 and i%3==0: print("Solo learn") elif i%3==0 and i%5!=0: print("solo") elif i%5==0 and i%3!=0: print("learn") else: print(i) Use this one bro
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message