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

python report-1

The document is a report on Python programming submitted by Shambhavi Kumari as part of her B.Tech in Biotechnology at Lovely Professional University. It covers the basics of Python, its applications in various fields, and includes sections on arithmetic operations, lists, the range function, perfect numbers, and other programming concepts. The conclusion emphasizes Python's versatility, user-friendliness, and its supportive community, making it a valuable tool for developers.

Uploaded by

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

python report-1

The document is a report on Python programming submitted by Shambhavi Kumari as part of her B.Tech in Biotechnology at Lovely Professional University. It covers the basics of Python, its applications in various fields, and includes sections on arithmetic operations, lists, the range function, perfect numbers, and other programming concepts. The conclusion emphasizes Python's versatility, user-friendliness, and its supportive community, making it a valuable tool for developers.

Uploaded by

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

REPORT LECTURES

Of
PYTHON

Submitted by:-
Shambhavi Kumari

REGISTRATION NUMBER:- 12318508


SECTION:-B2314
ROLL NO.:24

In partial fulfillment for the requirements of the award of the degree of


“Bachelors of Technology in Biotechnology”

“School of Bioengineering and Biosciences”

Lovely Professional University


Phagwara, Punjab.
INDEX:
Sl. no. Content Page Number

1. Introduction 3

2. Arithmetic Problems 4

3. Range 11

4. Perfect number 14

5. Conclusion 15
But, before understanding of program we have to understand what is
python and where does it helps us :

Python is a versatile, high-level programming language known for its


simplicity and readability. Developed by Guido van Rossum and first
released in 1991, it supports multiple programming paradigms, including
procedural, object-oriented, and functional programming. Python's easy-
to-understand syntax makes it popular for both beginners and experts,
while its extensive standard library allows for tasks like web development,
data analysis, automation, and more. It has a large, supportive community,
which contributes to its continuous growth, making it one of the most
widely used programming languages globally.

Python is widely used across various fields due to its simplicity,versatility,


and extensive libraries. Key uses include:

1. Web Development: Frameworks like Django and Flask are used to


build dynamic websites and web applications.
2. Data Science and Machine Learning: Libraries like NumPy,
pandas, TensorFlow, and PyTorch are popular for data analysis,
machine learning, and AI projects.
3. Automation: Python can automate repetitive tasks like file
handling, web scraping, and batch processing.
4. Game Development: It’s used to create simple games using
libraries like Pygame.
5. Scripting: Python is often used for writing scripts to automate
small tasks.
6. Software Development: It assists in prototyping and testing
software applications.

How to get start with python :

To get started with Python, you'll need to:


1. Install Python: Download and install Python from the official Python website.
2. Choose an IDE: Select a Python Integrated Development Environment (IDE)
like PyCharm, Visual Studio Code, or Spyder.
3. Write Your First Program: Create a new file with a .py extension and write
your first Python program!
HELLO WORLD! (most basic program)

Printing "Hello, World!" is a beginner-friendly way to learn the basic syntax of a programming
language and ensure the development environment is set up correctly. It’s a simple, confidence-
building step that helps verify everything is working before moving on to more complex coding tasks.

Arithmetic Operations:

In Python, arithmetic operations are fundamental mathematical operations that allow


you to perform calculations. Python supports the following basic arithmetic operators:

1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Floor Division (//)
6. Modulus (%)
7. Exponentiation (**)

Each of these operators is used to perform operations on numeric values, such as


integers and floats , we will see all the codes od these operators and how they function.
1. Addition (+)

The addition operator is used to add two numbers:

INPUT:

OUTPUT:

2. Subtraction (-):

The subtraction operator is used to subtract one number from another:

INPUT:
T

OUTPUT:

3. Multiplication (*):

The multiplication operator is used to multiply two numbers

INPUT:

OUTPUT:
4. Division (/):

The division operator divides one number by another and returns the result as a float:

INPUT:

OUTPUT:
5. Floor Division (//):

The floor division operator divides one number by another and returns the largest
integer value less than or equal to the division result:

INPUT:

OUTPUT:

6. Modulus (%):

The modulus operator returns the remainder of a division operation:

INPUT:
OUTPUT:

7. Exponentiation (**):

The exponentiation operator is used to raise a number to the power of another number:

INPUT:

OUTPUT:
\

Lists in Python: Creation, Entering, and Deletion:

A list in Python is a collection of items (or elements) that can store multiple values in
a single variable. Lists are one of Python's most flexible and commonly used data
structures because they can store items of different data types, and their size can
change dynamically. Lists are mutable, meaning their contents can be modified after
creation (e.g., items can be added or removed).

CREATING LISTS:

There are several ways to create a list in Python:

 Empty list: You can create an empty list using square brackets []

 List with elements:

Output:
 Entering Elements into Lists:

Output:

 This program shows the merging of two lists together.

INPUT:

OUTPUT:

This program showcases the following results:

1. Creating a final list by merging 2 lists


2. Sorting a list alphabetically plus adding a new member to the list
3. Printing of the sorted list in reverse order
4. Counting number of elements in the list
Input:

Output:

Precautions while Handling Lists:

 Ensure valid indexing to avoid index error.


 Remember that lists are mutable; changes to a list affect all references to it.
 Use list methods to modify lists instead of directly manipulating indices.

Lists in Python are versatile and provide various methods for entering, deleting, and
modifying elements. They are an essential part of Python's data structures and can be
used for dynamic and flexible data storage and manipulation.

RANGE():

The range() function in Python is used to generate a sequence of numbers. It is


commonly employed in loops to iterate over a specific number of times. You can
customize the sequence by specifying a start point, an endpoint, and a step size. This
makes it versatile for tasks such as looping through a fixed number of iterations,
creating sequences of numbers, and slicing lists.

Syntax of range():

There are three ways to use range() based on the number of arguments passed:

1. Range(stop) :
Input:

Output:

2. Range (start, stop) :


Input:

Output:
Range (start, stop, step ) :

Input:

Output:

The range() function in Python is a versatile and powerful way to generate sequences
of numbers, commonly used in loops for iteration. It provides a convenient and
memory-efficient method to handle numerical ranges.

PERFECT NUMBER:

A perfect number is a positive integer that equals the sum of its proper divisors,
excluding itself. For instance, 6 is perfect because its divisors (1, 2, and 3) sum to 6.
Similarly, 28 is perfect because its divisors (1, 2, 4, 7, and 14) sum to 28. These
numbers are significant in number theory for their unique properties.

Example:

 6 is a perfect number:
o Proper divisors of 6: 1, 2, 3
o Sum of divisors: 1 + 2 + 3 = 6
 28 is another perfect number:
o Proper divisors of 28: 1, 2, 4, 7, 14
o Sum of divisors: 1 + 2 + 4 + 7 + 14 = 28

Perfect numbers are rare, and the first few perfect numbers are 6, 28, 496, and 8128.
Program for Perfect numbers:

Perfect numbers between specified range:

Input:
Output:

Program to check if any number is perfect number or not :

Input:

Output:
FACTORIAL NUMBER
A factorial number represents the product of all positive integers less than or equal to
that
number. It's denoted by the symbol "!".
Formula:
• n! = n × (n-1) × (n-2) × ... × 2 × 1
Examples:
• 0! = 1 (by definition)
• 1! = 1
• 2! = 2 × 1 = 2
• 3! = 3 × 2 × 1 = 6
• 4! = 4 × 3 × 2 × 1 = 24
Print The Length of a Given Sequence:
INPUT:

OUTPUT:

Fibonacci Series:
The Fibonacci series is a sequence of numbers where each number is the sum of the
two
preceding ones. It starts with 0 and 1, and the sequence continues as follows:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...

Formula:
F(n) = F(n-1) + F(n-2)
Where:
• F(n) is the nth Fibonacci number.
• F(n-1) is the (n-1)th Fibonacci number.
• F(n-2) is the (n-2)th Fibonacci number.

Applications of Fibonacci Series:


The Fibonacci series appears in various natural phenomena and mathematical
concepts:

• Nature:
22o The arrangement of leaves on a stem
o The branching of trees
o The spiral patterns in pinecones and sunflowers
o The growth patterns of some plants
• Mathematics:
o Golden ratio
o Fractals
o Algorithms and data structures
• Computer Science:
o Searching and sorting algorithms
o Data compression
o Game theory

Implementing Fibonacci Series in Python:

INPUT:

OUTPUT:
Armstrong Number:
An Armstrong number is a number that is equal to the sum of its own digits, each
raised to the power of the number of digits.
Example:
Consider the number 153.
• It has 3 digits.
• 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
Since the sum of the cubes of its digits equals the number itself, 153 is an Armstrong
number.
Other examples of Armstrong numbers:
23• 0
•1
• 370
• 371
• 407

INPUT:

OUTPUT:
Declaration of Variables to store the count values:

Creating an Empty Stack:


An empty stack in Python is a stack data structure that contains no
elements. It is essentially an empty list or an empty deque.
Key characteristics of an empty stack:

• Size: 0
• Top element: None (since there's no element to be on top)
• Operations:
o Push: Adds an element to the top of
the stack.
o Pop: Removes and returns the top
element from the stack. This
operation is not possible on an
empty stack.
o Peek: Returns the top element
without removing it. This operation
is not possible on an empty stack.
o IsEmpty: Returns True if the stack
is empty.

INPUT:
OUTPUT:
Excel File Handling:
Specify the column name and get its index:
CONCLUSION
In conclusion, Python has proven to be a powerful, adaptable, and user-
friendly programming language. It has shown to be a fantastic choice for
developers working in a range of fields, including web development, data
science, machine learning, and automation, because of its simplicity of
use and large library ecosystem. Dynamic typing makes Python easy to
use for beginners and robust enough for experts to tackle complex tasks;
its simple syntax encourages readability and streamlines functionality.

Python's large and friendly community and cross-platform compatibility


ensure that it will continue to develop and adapt to new technological
trends. All things considered, learning and using Python opens up a
world of possibilities, promoting efficient problem-solving as well as
imaginative project creation and management in the modern digital world.

You might also like