filmov
tv
Code 98: Tech Mahindra - Odd Even Difference Program | Tech Mahindra Coding | 365 Days of Code

Показать описание
Odd Even Difference
Write a program to return the difference between the sum of odd and even numbers from an array of positive integers.
Note:
You are expected to write code in the findOddEvenDifference function only which will receive the first parameter as the number of items in the array and second parameter as the array itself. You are not required to take input from the console
Example:
Finding the difference between the sum of odd even numbers from a list of 5 numbers
Input
5
10 11 7 12 14
Output
-18
Explanation
Sum of Odd - Sum of Even = 18-36 = -18
"""
n = int(input())
num_list = list(map(int, input().split()))
even_sum = 0
odd_sum = 0
for each in num_list:
if each % 2 == 0:
even_sum += each
else:
odd_sum += each
print(odd_sum - even_sum)
# Thanks
Write a program to return the difference between the sum of odd and even numbers from an array of positive integers.
Note:
You are expected to write code in the findOddEvenDifference function only which will receive the first parameter as the number of items in the array and second parameter as the array itself. You are not required to take input from the console
Example:
Finding the difference between the sum of odd even numbers from a list of 5 numbers
Input
5
10 11 7 12 14
Output
-18
Explanation
Sum of Odd - Sum of Even = 18-36 = -18
"""
n = int(input())
num_list = list(map(int, input().split()))
even_sum = 0
odd_sum = 0
for each in num_list:
if each % 2 == 0:
even_sum += each
else:
odd_sum += each
print(odd_sum - even_sum)
# Thanks
Code 98: Tech Mahindra - Odd Even Difference Program | Tech Mahindra Coding | 365 Days of Code
Code 99: Tech Mahindra - Find Total Feet Program | Tech Mahindra Coding | 365 Days of Code
how to clean fuel injectors
Code 100: Tech Mahindra - Calculate Total Tax Program | Tech Mahindra Coding | 365 Days of Code
Bypass Immobilizer | How To Bypass Immobilizer | #youtube #automobile #mechanic #ytshorts #video
Tech Mahindra Coding Solution | Find Odd-Even Difference | Code In Python
Check Engine Codes WITHOUT Scan Tool. Link to full video in the description.
Clean oxygen sensor#automobile #skills #car #tips #mechanic
How to Test Heated Oxygen Sensor. #automobile #carrepairtips #carmaintenancetips #carinspection
#golfswing #fyp #waitforit #followthrough
Adjust Your Boost Pressure | #turbo
piston rings position
Affordable OBD 2 scanner #foxwell link in bio #fyp #mechanic #autodiagnostico #obdscanner
TEST YOUR ALTERNATOR TO MAKE SURE IT’S GOOD. #shorts #youtubeshorts
Electronic Control Units (ECU) repair
Old mahindra 575 power steering fitting 🚜🔥
Tech Mahindra Coding Part Complete Solution | Tech Test |
How to open a car if you left the key inside the car
gas pe khade ho gaye ladki | vj pawan singh | shorts
Mahindra Tractor Hydraulic Oil level #shorts
96mph R/C Drag Car! #shorts
New mahindra 585 di power plus 50hp # #music #automobile #mahindrapowerol #mahindraindia #mahindra
Tech Mahindra 2021 all Coding questions solution | Tech Mahindra Cognitive Test Questions | Non-SDE
Bcm body control module located behind the dash #honda #mechanic #mechanictools #repair #mecanica
Комментарии