SlideShare a Scribd company logo
2
Most read
4
Most read
9
Most read
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


More Related Content

PDF
python practicals-solution-2019-20-class-xii.pdf
PPT
Packages in java
PDF
Basic Photoshop
PPTX
Patterns and Practices in Building Office Add-ins
PDF
Photoshop ders notları
PPT
Introduction to Photoshop
PPTX
Iterarators and generators in python
PDF
Dynamic memory allocation
python practicals-solution-2019-20-class-xii.pdf
Packages in java
Basic Photoshop
Patterns and Practices in Building Office Add-ins
Photoshop ders notları
Introduction to Photoshop
Iterarators and generators in python
Dynamic memory allocation

What's hot (20)

PPTX
DIAGRAMME DE SEQUENCE.pptx
PPTX
Android share preferences
PPTX
Concept of OOPS with real life examples
PDF
CS3391 -OOP -UNIT – V NOTES FINAL.pdf
PPTX
Advanced Python : Decorators
PDF
Arrays in java
PDF
Python tuple
PPTX
Python Datatypes by SujithKumar
DOCX
Macromedia Flash Player Practical file
PPT
Google sketch up tutorial
PPTX
File handling in c++
PDF
Photoshop Tutorial
PDF
Python functions
PDF
Python-List comprehension
PPTX
Adobe Photoshop for Beginners
PDF
Python Workshop Part 2. LUG Maniapl
PDF
Doubly Linked List
PPTX
Explicacion de pygame para python de la UTN de Argentina
PPTX
Java awt (abstract window toolkit)
PDF
Python tuples and Dictionary
DIAGRAMME DE SEQUENCE.pptx
Android share preferences
Concept of OOPS with real life examples
CS3391 -OOP -UNIT – V NOTES FINAL.pdf
Advanced Python : Decorators
Arrays in java
Python tuple
Python Datatypes by SujithKumar
Macromedia Flash Player Practical file
Google sketch up tutorial
File handling in c++
Photoshop Tutorial
Python functions
Python-List comprehension
Adobe Photoshop for Beginners
Python Workshop Part 2. LUG Maniapl
Doubly Linked List
Explicacion de pygame para python de la UTN de Argentina
Java awt (abstract window toolkit)
Python tuples and Dictionary
Ad

Similar to Python program For O level Practical (20)

PDF
xii cs practicals class 12 computer science.pdf
PDF
Xi CBSE Computer Science lab programs
PDF
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
DOCX
python file for easy way practicle programs
PDF
xii cs practicals
PDF
Python summer course play with python (lab1)
PDF
Python summer course play with python (lab1)
PDF
III MCS python lab (1).pdf
PPTX
Loops in Python
PDF
datastructure-1 lab manual journals practical
PPTX
Working with functions.pptx. Hb.
PDF
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
DOCX
Basic python laboratoty_ PSPP Manual .docx
PDF
Advanced Web Technology ass.pdf
PDF
analysis of data structure design programs
PPTX
Python programming workshop session 3
PPTX
luckfuckfunctioneekefkfejewnfiwnfnenf.pptx
PPTX
Python programming workshop session 4
DOCX
Python Laboratory Programming Manual.docx
DOCX
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
xii cs practicals class 12 computer science.pdf
Xi CBSE Computer Science lab programs
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
python file for easy way practicle programs
xii cs practicals
Python summer course play with python (lab1)
Python summer course play with python (lab1)
III MCS python lab (1).pdf
Loops in Python
datastructure-1 lab manual journals practical
Working with functions.pptx. Hb.
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
Basic python laboratoty_ PSPP Manual .docx
Advanced Web Technology ass.pdf
analysis of data structure design programs
Python programming workshop session 3
luckfuckfunctioneekefkfejewnfiwnfnenf.pptx
Python programming workshop session 4
Python Laboratory Programming Manual.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
Ad

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Lesson notes of climatology university.
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Computing-Curriculum for Schools in Ghana
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
01-Introduction-to-Information-Management.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Pharma ospi slides which help in ospi learning
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Lesson notes of climatology university.
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Computing-Curriculum for Schools in Ghana
Anesthesia in Laparoscopic Surgery in India
Microbial diseases, their pathogenesis and prophylaxis
01-Introduction-to-Information-Management.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Cell Structure & Organelles in detailed.
Supply Chain Operations Speaking Notes -ICLT Program
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pharma ospi slides which help in ospi learning
STATICS OF THE RIGID BODIES Hibbelers.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
A systematic review of self-coping strategies used by university students to ...
Abdominal Access Techniques with Prof. Dr. R K Mishra
GDM (1) (1).pptx small presentation for students
Final Presentation General Medicine 03-08-2024.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf

Python program For O level Practical

  • 1. 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.
  • 2.  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
  • 3.  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 
  • 4.  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
  • 5.  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]))
  • 6.  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)) 
  • 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:  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
  • 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 