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

python program

The document contains a collection of Python programming examples suitable for Class 9 CBSE AI curriculum, covering basic programs, input-based programs, list operations, and conditional and loop-based programs. Each section includes simple code snippets demonstrating various programming concepts such as printing, calculations, and list manipulations. The examples aim to provide foundational knowledge and practical skills in Python programming.

Uploaded by

helena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

python program

The document contains a collection of Python programming examples suitable for Class 9 CBSE AI curriculum, covering basic programs, input-based programs, list operations, and conditional and loop-based programs. Each section includes simple code snippets demonstrating various programming concepts such as printing, calculations, and list manipulations. The examples aim to provide foundational knowledge and practical skills in Python programming.

Uploaded by

helena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Your PDF contains Python programming topics from the textbook.

Here are the **Python


programs** covered in your document:

### **Basic Python Programs**


1. **Printing Personal Information**
```python
print("Name: Sachin")
print("Father’s Name: Mr. Kumar")
print("Class: 9")
print("School Name: KV Mysore")
```

2. **Printing Patterns**
```python
print("*")
print("**")
print("***")
print("****")
print("*****")
```

3. **Finding the Square of a Number**


```python
num = 7
print("Square of", num, "is", num ** 2)
```

4. **Summing Two Numbers**


```python
a = 15
b = 20
sum = a + b
print("Sum:", sum)
```

5. **Converting Kilometers to Meters**


```python
km = float(input("Enter distance in kilometers: "))
meters = km * 1000
print("Distance in meters:", meters)
```

6. **Printing Multiplication Table of 5**


```python
for i in range(1, 6):
print("5 x", i, "=", 5 * i)
```
7. **Calculating Simple Interest**
```python
principal = 2000
rate = 4.5
time = 10
simple_interest = (principal * rate * time) / 100
print("Simple Interest:", simple_interest)
```

### **Input-Based Programs**


8. **Calculating Area and Perimeter of a Rectangle**
```python
length = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))
area = length * breadth
perimeter = 2 * (length + breadth)
print("Area:", area)
print("Perimeter:", perimeter)
```

9. **Calculating Area of a Triangle**


```python
base = float(input("Enter base: "))
height = float(input("Enter height: "))
area = 0.5 * base * height
print("Area of Triangle:", area)
```

10. **Calculating Average Marks**


```python
sub1 = float(input("Enter marks of subject 1: "))
sub2 = float(input("Enter marks of subject 2: "))
sub3 = float(input("Enter marks of subject 3: "))
avg = (sub1 + sub2 + sub3) / 3
print("Average Marks:", avg)
```

### **Python Lists**


11. **Basic List Operations**
```python
quiz_participants = ["Arjun", "Sonakshi", "Vikram", "Sandhya", "Sonal", "Isha", "Kartik"]
print(quiz_participants) # Print full list
quiz_participants.remove("Vikram") # Remove Vikram
quiz_participants.append("Jay") # Add Jay
del quiz_participants[1] # Remove second element
print(quiz_participants)
```
12. **List Indexing & Slicing**
```python
num_list = [23, 12, 5, 9, 65, 44]
print("Length of list:", len(num_list))
print("Elements from 2nd to 4th:", num_list[1:4])
print("Elements from 3rd to 5th using negative indexing:", num_list[-4:-1])
```

13. **Adding Elements to a List**


```python
List_1 = [10, 20, 30, 40]
List_1.extend([14, 15, 12])
List_1.sort() # Sorting in ascending order
print("Updated List:", List_1)
```

### **Conditional and Loop-Based Programs**


14. **Checking Voting Eligibility**
```python
age = int(input("Enter your age: "))
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
```

15. **Checking Student Grade**


```python
marks = int(input("Enter your marks: "))
if marks >= 90:
print("Grade: A")
elif marks >= 75:
print("Grade: B")
elif marks >= 60:
print("Grade: C")
else:
print("Grade: D")
```

16. **Checking if a Number is Positive, Negative, or Zero**


```python
num = int(input("Enter a number: "))
if num > 0:
print("Positive Number")
elif num < 0:
print("Negative Number")
else:
print("Zero")
```

17. **Printing First 10 Natural Numbers**


```python
for i in range(1, 11):
print(i)
```

18. **Printing First 10 Even Numbers**


```python
for i in range(2, 21, 2):
print(i)
```

19. **Printing Odd Numbers from 1 to n**


```python
n = int(input("Enter value of n: "))
for i in range(1, n+1, 2):
print(i)
```

20. **Finding the Sum of First 10 Natural Numbers**


```python
sum_natural = sum(range(1, 11))
print("Sum of first 10 natural numbers:", sum_natural)
```

21. **Finding the Sum of All Elements in a List**


```python
numbers = [10, 20, 30, 40, 50]
print("Sum of list:", sum(numbers))
```

---

These programs are extracted from your **textbook PDF** and are aligned with **Class 9
CBSE AI curriculum**.

Would you like me to explain any specific **Python concepts** in more detail? 😊📚
\

You might also like