0% found this document useful (0 votes)
3 views1 page

Class8 CBSE Python Programs

This document contains Python programs suitable for Class 8 CBSE students. It includes examples for printing 'Hello World', adding two numbers, checking even or odd numbers, finding the largest of three numbers, generating a multiplication table, calculating factorials, producing a Fibonacci series, and checking for palindromes. Each program is presented with code snippets for easy understanding and implementation.

Uploaded by

pihusahai283
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 views1 page

Class8 CBSE Python Programs

This document contains Python programs suitable for Class 8 CBSE students. It includes examples for printing 'Hello World', adding two numbers, checking even or odd numbers, finding the largest of three numbers, generating a multiplication table, calculating factorials, producing a Fibonacci series, and checking for palindromes. Each program is presented with code snippets for easy understanding and implementation.

Uploaded by

pihusahai283
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 8 CBSE Python Programs

1. Print Hello World


print("Hello, World!")

2. Add Two Numbers


a = int(input("Enter first number: ")) b = int(input("Enter second number: "))
print("Sum =", a + b)

3. Check Even or Odd


num = int(input("Enter a number: ")) if num % 2 == 0: print(num, "is Even") else:
print(num, "is Odd")

4. Find 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:", a) elif b >
c: print("Largest:", b) else: print("Largest:", c)

5. Multiplication Table
n = int(input("Enter a number: ")) for i in range(1, 11): print(n, "x", i, "=", n*i)

6. Factorial of a Number
n = int(input("Enter a number: ")) fact = 1 for i in range(1, n+1): fact *= i
print("Factorial of", n, "is", fact)

7. Fibonacci Series
n = int(input("Enter number of terms: ")) a, b = 0, 1 print("Fibonacci Series:") for
i in range(n): print(a, end=" ") a, b = b, a + b

8. Palindrome Check
text = input("Enter a word: ") if text == text[::-1]: print("Palindrome") else:
print("Not Palindrome")

You might also like