+ 2

Plz can someone help me ??

Write a program in python and an algorithm with algobox named SOM_CHIFFRES, which allows to determine the sum of the digits of a given integer X. Example: for N = 26418, we will have 2 + 6 + 4 + 1 + 8 = 21) Change the program to test if x divisible by 3 (algo and pg) in the same folder. Rq: a number is divisible by 3 if the sum of these digits and divisible by 3

9th Dec 2019, 5:36 PM
oussama
oussama - avatar
14 Antworten
+ 4
If you break it down, this task is actually quite simple. You try to write this program. If something isn’t working, ask for help. We won’t do your work for you, only point you in the right direction
9th Dec 2019, 5:44 PM
Jax
Jax - avatar
+ 4
You don’t need to be smart in mathematics. If you’re struggling with this, you really need to pay attention in class and make sure you understand what your professor is saying. Ask questions if you need to, just be sure to understand
9th Dec 2019, 5:49 PM
Jax
Jax - avatar
+ 4
oussama Looks like you don't have much idea about basic syntax in python, I would suggest to see some 1hr python video on youtube before exam. Here is the modified code: a=int(input("donner votre:")) S=0 while(a!=0): S=S+(a%10) a=a//10 print(S)
9th Dec 2019, 9:28 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
Well I'll give you what I reached and can you plz fix it for me
9th Dec 2019, 5:50 PM
oussama
oussama - avatar
+ 1
Absolutely. As long as you attempt and give it your all, I have no problem helping you
9th Dec 2019, 5:52 PM
Jax
Jax - avatar
0
-use // operator to do integer division by 10, to remove last digit of a number -use n%10 to take last out last digit on integer n. -make a loop while n is not equal to 0, in each iteration take out last digit of n and add it to some variable sum, and remove last digit from n(modify value of n). -after loop, check value of sum%3==0.
9th Dec 2019, 5:43 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
0
It's just 4 lines
9th Dec 2019, 5:46 PM
oussama
oussama - avatar
0
I have an exam tomorrow and I haven't found a solution for this
9th Dec 2019, 5:46 PM
oussama
oussama - avatar
0
Thx
9th Dec 2019, 5:52 PM
oussama
oussama - avatar
- 1
I know but I'm not smart in mathematics
9th Dec 2019, 5:45 PM
oussama
oussama - avatar
- 1
a=int(input(donner votre:)) S=0 b=0 While b=a%10//10 Print(b)
9th Dec 2019, 5:55 PM
oussama
oussama - avatar
- 1
I mean a=int(input(donner votre:)) S=0 While S=a%10//10 Print(b)
9th Dec 2019, 5:56 PM
oussama
oussama - avatar
- 1
def divi3(x): a=0 for i in str(x): a=a+int(i) if not a % 3: return 1 else: return 0 divi3(4536)
11th Dec 2019, 1:27 PM
小于国际
小于国际 - avatar