0

[SOLVED] About the FuzzBuzz project

n = 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?

20th Jan 2021, 10:18 PM
Albanianz
Albanianz - avatar
20 Antworten
+ 3
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
20th Jan 2021, 10:43 PM
Albanianz
Albanianz - avatar
+ 3
Great!
20th Jan 2021, 10:57 PM
Abhay
Abhay - avatar
+ 3
#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
22nd Jan 2021, 12:19 AM
br0k3n
br0k3n - avatar
+ 2
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.
20th Jan 2021, 10:49 PM
Abhay
Abhay - avatar
+ 2
Albanianz if you still have doubt related to the output you can ask me anytime!
20th Jan 2021, 10:54 PM
Abhay
Abhay - avatar
+ 2
Thanks
21st Jan 2021, 9:57 AM
Albanianz
Albanianz - avatar
+ 1
Abhay I still don't understand it, can you explain it simplier or with more details?
20th Jan 2021, 10:29 PM
Albanianz
Albanianz - avatar
+ 1
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.
20th Jan 2021, 10:40 PM
Abhay
Abhay - avatar
+ 1
Yes I misunderstood something but it's clear now thanks
20th Jan 2021, 10:55 PM
Albanianz
Albanianz - avatar
+ 1
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
20th Jan 2021, 10:58 PM
Albanianz
Albanianz - avatar
+ 1
Albanianz yes , import random print(random.randint(1,1000))
20th Jan 2021, 11:08 PM
Abhay
Abhay - avatar
+ 1
Msg me for any further queries on this program
21st Jan 2021, 10:29 AM
lakshmi pathi
lakshmi pathi - avatar
+ 1
Thanks I had already solved the project but wondered why it was "0" and got the answer from Abhay
21st Jan 2021, 10:32 AM
Albanianz
Albanianz - avatar
+ 1
https://www.sololearn.com/coach/612?ref=app this is the correct fizz buzz program u can try this Albanianz
22nd Jan 2021, 5:32 AM
S. V. Shivaani
S. V. Shivaani - avatar
0
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.
20th Jan 2021, 10:26 PM
Abhay
Abhay - avatar
0
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
21st Jan 2021, 10:27 AM
lakshmi pathi
lakshmi pathi - avatar
0
Bro it's not getting crct output
22nd Jan 2021, 2:08 AM
lakshmi pathi
lakshmi pathi - avatar
0
x = int(input()) if x > 5: if x < 8: print(x+1) else: print(x-1) else: print(x) A) 8
14th Nov 2022, 2:09 PM
Avdi Hyseni
Avdi Hyseni - avatar
- 1
thnwjjwnnaiwjnwjwuahuajbsksnhsms
22nd Jan 2021, 3:46 AM
DYLAN TOBIN
DYLAN TOBIN - avatar