0% found this document useful (0 votes)
18 views

Computer Science Assignment Parth Kakkar Xi-B 5124

The document describes a computer science assignment that involves taking user input of numbers into a list, removing the largest odd number from the list if it exists, and printing the largest even number or a message if the list is empty. A second part of the assignment involves summing the even and odd indexed elements of a user-input list of numbers and printing the differences.

Uploaded by

Parth Kakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Computer Science Assignment Parth Kakkar Xi-B 5124

The document describes a computer science assignment that involves taking user input of numbers into a list, removing the largest odd number from the list if it exists, and printing the largest even number or a message if the list is empty. A second part of the assignment involves summing the even and odd indexed elements of a user-input list of numbers and printing the differences.

Uploaded by

Parth Kakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

COMPUTER SCIENCE

ASSIGNMENT
PARTH KAKKAR
XI-B
5124
lst = []
n1 = int(input(“enter number of elements”))
for I in range(n1):
n2 = int(input(“enter elements”))
lst.append(n2)
for j in lst:
n3 = max(lst)
if n3 % 2 != 0:
lst.remove(n3)
if len(lst) == 1:
lst =[]
n4 = len(lst)
if n4 == 0:
print(“No even number”)
elif n4 > 0:
print(“largest even number:”, n3
OUTPUT
"lst = []
sum = 0
s=0
n1 = int(input("enter number of elements:"))
for i in range(n1):
n2 = int(input("enter elements:"))
lst.append(n2)
for j in range(n1):
if j % 2 == 0:
sum += lst[j]
elif j % 2 != 0:
s += lst[j]
print("sum of even indexes :", sum)
print("sum of odd indexes :", s)
print("sum of even indexes minus sum of
odd indexes:", sum - s)
OUTPUT

You might also like