Study Gang discussion

29 views
Subjects > Computer Science

Comments Showing 1-15 of 15 (15 new)    post a comment »
dateUp arrow    newest »

message 1: by phideɭia (new)

phideɭia (did-you-say-phi) | 158 comments Mod
^^


Apple˚✧ (ia-study) | 44 comments the subject which makes the avg grades go higher 😌


message 3: by veera ♡ (new)

veera ♡ but my motivation go lower


message 4: by [deleted user] (new)

Apple˚✧ wrote: "the subject which makes the avg grades go higher 😌"

yeahhh


Apple˚✧ (ia-study) | 44 comments Veera♡ wrote: "but my motivation go lower"

true tho 😭


message 6: by HN (new)

HN | 1 comments Omg I’m studying this in university rn😝


message 7: by [deleted user] (new)

Can someone please please pleeease help me understand what armstrong number is and how this code is meant to help verify if a number is armstrong number or not, I CANT UNDERSTAND IT
n=int(input("enter:"))
sum=0
x=n
while n!=0:
a=n%10
sum=sum+a**3
n=n//10
if sum==x:
print("yes")
else:
print("no")


message 8: by phideɭia (new)

phideɭia (did-you-say-phi) | 158 comments Mod
Dorcas wrote: "Can someone please please pleeease help me understand what armstrong number is and how this code is meant to help verify if a number is armstrong number or not, I CANT UNDERSTAND IT
n=int(input("en..."


armstrong number is a number that equals the sum of its digit's cubes


message 9: by phideɭia (new)

phideɭia (did-you-say-phi) | 158 comments Mod
153 is an armstrong number


message 10: by phideɭia (new)

phideɭia (did-you-say-phi) | 158 comments Mod
1^3+ 5^3 + 3^3 =153 ,


message 11: by phideɭia (last edited Jun 04, 2024 06:32AM) (new)

phideɭia (did-you-say-phi) | 158 comments Mod
Dorcas wrote: "Can someone please please pleeease help me understand what armstrong number is and how this code is meant to help verify if a number is armstrong number or not, I CANT UNDERSTAND IT
n=int(input("en..."


% stands for modulo - it gives the remainder
// stands for floor division - it gives the greatest integer function of the quotient

so, basically you're obtaining a number for input as n, and taking initial sum as 0
you're assigning x the value of 'n' to keep it aside for equating it with the sum of its cubes while operating on 'n'
then, in the while loop (while ensuring n doesn't become 0):
1) you're obtaining the last digit of n and assigning it to 'a'
2) then, updating the value of 'sum' which you would have to check if it's equal with the original number later
3) now, you're updating n, by removing its last digit
then, it goes back in the loop
finally, you're checking if 'x' equals with the 'sum', if yes, then the output is yes, else, it's no.

I have a simple, alternative code though:
n= int(input('Enter no.: '))
s=str(n)
sum=0
for a in s:
sum+=int(a)**3
if sum==n:
print(n, ' is armstrong')

(with appropriate indentation ofc)


message 12: by phideɭia (new)

phideɭia (did-you-say-phi) | 158 comments Mod
Dorcas wrote: "Can someone please please pleeease help me understand what armstrong number is and how this code is meant to help verify if a number is armstrong number or not, I CANT UNDERSTAND IT
n=int(input("en..."


did you get it now? :)


message 13: by [deleted user] (new)

YEAAHHHHH!!!! I GOT IT OMG THANKS A LOT PHIDELIAA :D <3


message 14: by phideɭia (new)

phideɭia (did-you-say-phi) | 158 comments Mod
Dorcas wrote: "YEAAHHHHH!!!! I GOT IT OMG THANKS A LOT PHIDELIAA :D <3"

Welcome :)


message 15: by Anshika (new)

Anshika  | 121 comments Guys, I need help!!
I was writing Java programs, and I realized I had forgotten some minor concepts from my previous academic year (class 10th). So, I need to revise it. Can you suggest me how can I revise those topics in less time?(cause I have only a week left for school)


back to top