Python is a well-liked programming language. It was
developed by Guido van Rossum in 1991. It is used for
web development (server-side), software development,
mathematics, system scripting. Python was designed for
readability, and has some similarities to the English
language with manipulate from mathematics.
 Program:
 def fact(n):
 if n == 0:
 return 1
 else:
 return n * fact(n-1)
 n=int(input("Enter a number for compute the
factorial : "))
 print(fact(n))
 Output:
 Enter a number for compute the factorial : 4
 24
 Program:
 import numpy as np
 x = np.array([1,2,3,4,5,7,2,1,1,1,8,9,1])
 print(x)
 print("most frequent value in the list:")
 print(np.bincount(x).argmax())

 Output:

 [1 2 3 4 5 7 2 1 1 1 8 9 1]
 most frequent value in the list:
 1

 Program:
 print("Enter words separated by Hyphens : ")
 lst = [n for n in input().split("-")]
 lst.sort()
 print('-'.join(lst))

 Output:
 Enter words separated by Hyphens :
 gaurav-ram-yashir-bittu-wong
 bittu-gaurav-ram-wong-yashir
 Program:
 def data(lst1, lst2):
 result = False
 for i in lst1:
 for j in lst2:
 if i == j:
 result = True
 return result
 print(data([1,2,3,4,5], [5,6,7,8,9,10]))
 Program:
 def fab(x):
 if x<2:
 return 1
 else:
 return fab(x-1)+fab(x-2)
 y=int(input("Enter a number :"))
 for i in range(y):
 print(i, "=", fab(i))

 Program:
 a = int(input("Enter the first number: "))
 b = int(input("Enter the second number: "))
 product = 0
 for i in range(b):
 product= product+a
 print(product)
 Output:
 Enter the first number: 3
 Enter the second number: 4
 12
 Program:
 Hello Students this program is very useful for O Level Practical so
read it carefully.
 def power(x,y):
 if y==0:
 return 1
 else:
 return x * power(x, y-1)
 x = float(input("Enter a value of base: "))
 y = int(input("Enter value of exponent: "))
 result = power(x, y)
 print(result)
 Output:
 Enter a value of base: 2
 Enter value of exponent: 3
 8.0
 mydict = {'raj': 5, 'raja': 6,
 'sanju': 7, 'mohan': 2, 'surya': 10}
 Keys = list(mydict.keys())
 Keys.sort()
 sort_dict = {i: mydict[i] for i in Keys}
 print(sort_dict)
 list = []
 num = int(input("Enter number of elements in list: "))
 for i in range(1, num + 1):
 a = int(input("Enter elements: "))
 list.append(a)
 print("Largest element is:", max(list))
 Output:
 Enter number of elements in list: 3
 Enter elements: 19
 Enter elements: 13
 Enter elements: 88
 Largest element is: 88
 More python Program click below link
 https://www.careerbodh.in/blog/categories/python-program


Python program For O level Practical

  • 1.
    Python is awell-liked programming language. It was developed by Guido van Rossum in 1991. It is used for web development (server-side), software development, mathematics, system scripting. Python was designed for readability, and has some similarities to the English language with manipulate from mathematics.
  • 2.
     Program:  deffact(n):  if n == 0:  return 1  else:  return n * fact(n-1)  n=int(input("Enter a number for compute the factorial : "))  print(fact(n))  Output:  Enter a number for compute the factorial : 4  24
  • 3.
     Program:  importnumpy as np  x = np.array([1,2,3,4,5,7,2,1,1,1,8,9,1])  print(x)  print("most frequent value in the list:")  print(np.bincount(x).argmax())   Output:   [1 2 3 4 5 7 2 1 1 1 8 9 1]  most frequent value in the list:  1 
  • 4.
     Program:  print("Enterwords separated by Hyphens : ")  lst = [n for n in input().split("-")]  lst.sort()  print('-'.join(lst))   Output:  Enter words separated by Hyphens :  gaurav-ram-yashir-bittu-wong  bittu-gaurav-ram-wong-yashir
  • 5.
     Program:  defdata(lst1, lst2):  result = False  for i in lst1:  for j in lst2:  if i == j:  result = True  return result  print(data([1,2,3,4,5], [5,6,7,8,9,10]))
  • 6.
     Program:  deffab(x):  if x<2:  return 1  else:  return fab(x-1)+fab(x-2)  y=int(input("Enter a number :"))  for i in range(y):  print(i, "=", fab(i)) 
  • 7.
     Program:  a= int(input("Enter the first number: "))  b = int(input("Enter the second number: "))  product = 0  for i in range(b):  product= product+a  print(product)  Output:  Enter the first number: 3  Enter the second number: 4  12
  • 8.
     Program:  HelloStudents this program is very useful for O Level Practical so read it carefully.  def power(x,y):  if y==0:  return 1  else:  return x * power(x, y-1)  x = float(input("Enter a value of base: "))  y = int(input("Enter value of exponent: "))  result = power(x, y)  print(result)  Output:  Enter a value of base: 2  Enter value of exponent: 3  8.0
  • 9.
     mydict ={'raj': 5, 'raja': 6,  'sanju': 7, 'mohan': 2, 'surya': 10}  Keys = list(mydict.keys())  Keys.sort()  sort_dict = {i: mydict[i] for i in Keys}  print(sort_dict)
  • 10.
     list =[]  num = int(input("Enter number of elements in list: "))  for i in range(1, num + 1):  a = int(input("Enter elements: "))  list.append(a)  print("Largest element is:", max(list))  Output:  Enter number of elements in list: 3  Enter elements: 19  Enter elements: 13  Enter elements: 88  Largest element is: 88  More python Program click below link  https://www.careerbodh.in/blog/categories/python-program 