Posts

Write a Python function to print the numbers of a specified list after removing even numbers from it.

Image
# Write a Python function to print the numbers of a specified list after removing even numbers from it def re(): li = [1,2,3,4,5,6,7,8,9] for i in li : if i % 2 == 0: li.remove(i) print(li) re() نسخ

Write a python function that takes two lists and prints True if they have at least one common member.

Image
# Write a python function that takes two lists and prints True if they have at least one common member. def k(): li1 = [1,2,3,4,5] li2 = [6,7,1,9,22] for i in range (len(li1)): if li1[i] in li2 : print("True") k() نسخ

Write a python function to find the minimum number of a list.

Image
# Write a python function to find the minimum number of a list. def sm(): list2 = [166,22,4,66,77] small = list2[0] for i in list2 : if small > i: small = i print ("minimum number of a list ",small) sm() نسخ

Write a python function that takes a list from the user and then calculates the average of the list.

Image
def ave3(): list2 = [] sum2=0 z = int(input("size of the list")) for i in range (z): inn = int(input("enter the element")) list2.append(inn) for i in range (z): sum2=sum2+list2[i] a = sum2 / z print("average of the list = {}".format(a)) ave3() نسخ

Write a python function which calculates the factorial of a number.

Image
  # Write a python function which calculates the factorial of a number. def fact2(): fa = 1 x = int(input("enter the number")) for i in range (1,x+1): fa = fa * i print (fa) fact2() نسخ

Write a python function to calculate the sum between 2 numbers.

Image
  # Write a python function to calculate the sum between 2 numbers. z = int(input("enter the number")) x = int(input("enter the number")) def sum2(s,d): a = s + d print("sum between 2 numbers = ",a) sum2(z,x) نسخ