python program-1
python program-1
age = 14
student_class = "9th"
roll_number = 23
print("Student Details:")
print(f"Name: {name}")
print(f"Age: {age}")
print(f"Class: {student_class}")
#### **Output**
Student Details:
Age: 14
Class: 9th
Roll Number: 23
```python
if number % 2 == 0:
print(f"{number} is Even")
else:
print(f"{number} is Odd")
#### **Output**
Enter a number: 5
5 is Odd
if num % 2 == 0:
print(f"{num} is Even")
elif num % 5 == 0:
else:
#### **Output**
Enter a number: 25
25 is Divisible by 5
if num > 0:
print(f"{num} is Positive")
print(f"{num} is Negative")
else:
print("The number is Zero")
#### **Output**
Enter a number: -8
-8 is Negative
### **5. Program to Find the Greater Number Between Two Numbers**
if a > b:
print(f"{a} is Greater")
else:
print(f"{b} is Greater")
#### **Output**
12 is Greater
### **6. Program to Find the Greatest Number Among Three Numbers**
else:
#### **Output**
25 is the greatest
reverse_num = int(str(num)[::-1])
#### **Output**
#### **Output**
Sum of digits: 15
### **9. Program to Find the Length of a String**
#### **Output**
if operation == '+':
return a + b
return a - b
return a * b
return a / b
else:
print(f"Result: {result}")
#### **Output**
Result: 20.0
### **11. Program to Find Day of the Week According to Numbers (1-7)**
else:
print("Invalid input")
#### **Output**
if unit == "F":
celsius = (temp - 32) * 5 / 9
print(f"{temp}°F is {celsius:.2f}°C")
fahrenheit = (temp * 9 / 5) + 32
print(f"{temp}°C is {fahrenheit:.2f}°F")
else:
print("Invalid unit")
#### **Output**
98.6°F is 37.00°C
print(i)
#### **Output**
8
9
10
#### **Output**
#### **Output**
Enter a number: 5
5x1=5
5 x 2 = 10
...
5 x 10 = 50
### **16. Program to Calculate the Factorial of a Given Number**
factorial = 1
factorial *= i
#### **Output**
Enter a number: 5
Factorial of 5 is 120
#### **Output**
---
### **18. Program to Find Maximum and Minimum Number in a List**
#### **Output**
Maximum number: 89
Minimum number: 2
a, b = b, a
#### **Output**
Before swapping: a = 3, b = 7
After swapping: a = 7, b = 3
### **20. Program to Print All Prime Numbers Between 1 and 100**
if num % i == 0:
break
else:
#### **Output**
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97