s = int(input("Enter a digit: ")) s = str(s) odd, even = 0, 0 for i in range(len(s)): if i % 2 == 0: odd += int(s[i]) else: even += int(s[i]) print(abs(odd - even))
The code for Giveaway question is as follows: s=input("Please enter the Input : ") even_digitsum=0 odd_digitsum=0 for i in range(len(s)): if(i%2==0): even_digitsum=even_digitsum+int(s[i]) else: odd_digitsum=odd_digitsum+int(s[i]) diff=abs(even_digitsum-odd_digitsum) print("The even digit sum is :",even_digitsum) print("The odd digit sum is :" ,odd_digitsum) print("The difference between even and odd digit is : %d"%(diff))
given_list=input() new_list=[] even_digit=0 odd_digit=0 for i in given_list: new_list.append(int(i)) for i in range (len(new_list)): if (i%2==0): even_digit+=new_list[i] else: odd_digit+=new_list[i] if even_digit
here is the code for the question asked in the video: import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner= new Scanner(System.in); int sume=0; int sumo=0; String s= scanner.next(); for(int i=1;i
n=list(map(int,input())) sum_even=0 sum_odd=0 for i in range(len(n)): if i%2==0: sum_even=sum_even+n[i] else: sum_odd=sum_odd+n[i] print(abs(sum_even-sum_odd))
s = int(input("Enter a digit: "))
s = str(s)
odd, even = 0, 0
for i in range(len(s)):
if i % 2 == 0:
odd += int(s[i])
else:
even += int(s[i])
print(abs(odd - even))
The code for Giveaway question is as follows:
s=input("Please enter the Input : ")
even_digitsum=0
odd_digitsum=0
for i in range(len(s)):
if(i%2==0):
even_digitsum=even_digitsum+int(s[i])
else:
odd_digitsum=odd_digitsum+int(s[i])
diff=abs(even_digitsum-odd_digitsum)
print("The even digit sum is :",even_digitsum)
print("The odd digit sum is :" ,odd_digitsum)
print("The difference between even and odd digit is : %d"%(diff))
given_list=input()
new_list=[]
even_digit=0
odd_digit=0
for i in given_list:
new_list.append(int(i))
for i in range (len(new_list)):
if (i%2==0):
even_digit+=new_list[i]
else:
odd_digit+=new_list[i]
if even_digit
here is the code for the question asked in the video:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner scanner= new Scanner(System.in);
int sume=0;
int sumo=0;
String s= scanner.next();
for(int i=1;i
it will give wrong output bcoz in for loop it start with i=0 .
n=list(map(int,input()))
sum_even=0
sum_odd=0
for i in range(len(n)):
if i%2==0:
sum_even=sum_even+n[i]
else:
sum_odd=sum_odd+n[i]
print(abs(sum_even-sum_odd))
Waiting for video from prepinsta 🎉🎉🎉!!!
Coming soon!
Link for PrepInsta Prime: prepinstaprime.com/purchase
this is very nice to see and very helpful.
3rd Comment.
Glad it was helpful!
Launching TCS Crash Course, Checkout the registration link in the description!
Please tell me what will be the exact sections in tcs nqt exam if i have applied for HR role in IT
Kindly go though it's recruitment process on Prepinsta.com
Please upload more videos
We heard youuuuuu
2nd comment
1st comment
5th comment
GIVEAWAY QUESTION:
a=input('Enter a number: ')
e=0
o=0
for i in range(1,len(a)+1):
if(i%2==0):
e+=int(a[i-1])
else:
o+=int(a[i-1])
print(abs(e-o))