0% found this document useful (0 votes)
6 views3 pages

Class 11 CBSE Python Practical Programs

The document contains a collection of Python practical programs for Class 11 CBSE, covering various topics such as arithmetic operations, even or odd checks, finding the largest of three numbers, and generating Fibonacci series. It also includes examples of using NumPy for array operations, Pandas for DataFrame manipulation, and Matplotlib for creating graphs and charts. Additionally, it demonstrates a simple linear regression model using scikit-learn.

Uploaded by

studyonline13331
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)
6 views3 pages

Class 11 CBSE Python Practical Programs

The document contains a collection of Python practical programs for Class 11 CBSE, covering various topics such as arithmetic operations, even or odd checks, finding the largest of three numbers, and generating Fibonacci series. It also includes examples of using NumPy for array operations, Pandas for DataFrame manipulation, and Matplotlib for creating graphs and charts. Additionally, it demonstrates a simple linear regression model using scikit-learn.

Uploaded by

studyonline13331
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

Class 11 CBSE Python Practical Programs

FULL SOURCE CODE (2024–25)

1. Arithmetic Operations
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))

print("Addition =", a + b)
print("Subtraction =", a - b)
print("Multiplication =", a * b)

if b != 0:
print("Division =", a / b)
else:
print("Cannot divide by zero")

2. Even or Odd
n = int(input("Enter number: "))

if n % 2 == 0:
print("Even")
else:
print("Odd")

3. Largest of Three Numbers


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a > b and a > c:


print("Largest is", a)
elif b > c:
print("Largest is", b)
else:
print("Largest is", c)

4. Multiplication Table
n = int(input("Enter number: "))

for i in range(1, 11):


print(n, "x", i, "=", n * i)

5. Sum of Digits (While Loop)


n = int(input("Enter number: "))
sum = 0

while n > 0:
sum += n % 10
n //= 10

print("Sum of digits =", sum)

6. Fibonacci Series
n = int(input("Enter number of terms: "))

a, b = 0, 1
for i in range(n):
print(a, end=" ")
a, b = b, a + b

7. NumPy Array Operations


import numpy as np

arr1 = [Link]([1, 2, 3])


arr2 = [Link]([4, 5, 6])

print("Addition:", arr1 + arr2)


print("Multiplication:", arr1 * arr2)
print("Mean:", [Link](arr1))

8. Pandas DataFrame Operations


import pandas as pd

data = {
'Name': ['Aman', 'Riya', 'Kunal'],
'Marks': [85, 90, 78]
}

df = [Link](data)
df['Result'] = ['Pass', 'Pass', 'Pass']

print(df)
print([Link]())

9. Matplotlib Line Graph


import [Link] as plt

x = [1, 2, 3, 4]
y = [10, 20, 30, 40]

[Link](x, y)
[Link]("X-axis")
[Link]("Y-axis")
[Link]("Line Graph")
[Link]()

10. Bar & Scatter Chart


import [Link] as plt

players = ['Sachin', 'Virat', 'Rohit']


runs = [12000, 10000, 9000]

[Link](players, runs)
[Link]()

[Link](players, runs)
[Link]()

11. Simple Linear Regression


from sklearn.linear_model import LinearRegression
import numpy as np

X = [Link]([[1], [2], [3], [4]])


y = [Link]([2, 4, 6, 8])
model = LinearRegression()
[Link](X, y)

print("Prediction for X=5:", [Link]([[5]]))

You might also like