Answer the following questions(python programming class 10) 6. Finding...
1.# Python program to find the largest and smallest number in a list of number
# entering a list of number from user
list1=eval(input ("Enter a list of numbers:"))
length=len (list1)
# finding the largest and smallest number in the list
for i in range (0, length) :
maximum=max(list1)
minimum=min(list1)
# displaying largest and smallest number
print(" the largest number in the given list is:", maximum)
print(" the smallest number in the given list is:", minimum)
2.# Python program to insert a given element list/tuple of number
# entering a list from user
list1=eval(input ("Enter a list:"))
length=len(list1)
# entering the number from the user which has to be inserted in the given list
for i in range (0, length) :
num=int(input ("Enter a number:"))
index=int(input ("Enter index:"))
list1. insert(num, index)
# displaying the modified list
print(" the modified list after inserting the element is:", list1)
3.# Python program to find the sum of numbers in a number of list /tuple
# entering a list from user
list1=eval(input ("Enter a list:"))
# finding sum
sum_of _numbers_of _list1=sum(list1)
# displaying the sum
print(" the sum of the numbers in the given list is:", sum)
4.# Python program to find the square of even numbers and cube of odd numbers in a given list
# entering a list from user
list1=eval(input ("enter a list of numbers:"))
# creating empty list for Even and Odd numbers
even=[ ]
odd=[ ]
# finding Even and Odd numbers in the list
for in range (0, len (list1)) :
if [i] divided by 2==0:
even. append(i)
else:
odd. append(i)
# creating different list for the square of even number and cube of odd number
even_sq=[ ]
odd_cube=[ ]
for j in even:
[j]=j**2
even_sq.append(j)
for n in odd:
[n]=n**2
odd_cube.append(n)
# displaying the result
print(" the square of even number in the list is:", even_sq)
print(" the cube of odd number in the list is:", odd_cube)
5.# Python program to find the numbers which are divisible by 3 and 5 both
# entering a list from user
list1=eval(input (" enter a list of numbers:"))
# finding the numbers divisible by 3 and 5
divisible _by_3=[ ]
divisible _by_5=[ ]
for i in range (0, len (list 1)) :
if i divided by 3==0:
divisible_by_3.append(i)
elif:
if i divided by5==0:
divisible_by_5.append(i)
# displaying the result
print( "the numbers divisible by both 3 and 5 are:", divisible_by_3+divisible_by_5)
Answer the following questions(python programming class 10) 6. Finding...
To make sure you are not studying endlessly, EduRev has designed Class 10 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 10.