0% found this document useful (0 votes)
11 views4 pages

Class 12 Python Practical Programs

This document is a practical file for Class 12 Computer Science and Informatics Practices, containing ten Python programs with their respective questions, code, and outputs. The programs cover basic concepts such as printing text, arithmetic operations, conditional statements, loops, and functions like factorial and palindrome checks. Each program is designed to help students understand fundamental programming skills in Python.
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)
11 views4 pages

Class 12 Python Practical Programs

This document is a practical file for Class 12 Computer Science and Informatics Practices, containing ten Python programs with their respective questions, code, and outputs. The programs cover basic concepts such as printing text, arithmetic operations, conditional statements, loops, and functions like factorial and palindrome checks. Each program is designed to help students understand fundamental programming skills in Python.
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 12 – Python Practical File

Subject: Computer Science / Informatics Practices


Name: ____________________________
Class & Section: ___________________
Roll Number: ______________________
School Name: _______________________
Program 1: Print Hello World
Question: Write a program to print hello world.
Program:
print("Hello World")

Output:
Hello World

Program 2: Add Two Numbers


Question: Write a program to add two numbers.
Program:
a = 10
b = 20
print("Sum =", a + b)

Output:
Sum = 30

Program 3: Check Even or Odd


Question: Write a program to check even or odd.
Program:
n = 7
if n % 2 == 0:
print("Even")
else:
print("Odd")

Output:
Odd

Program 4: Largest of Two Numbers


Question: Write a program to largest of two numbers.
Program:
a = 15
b = 20
print("Greater number is", max(a, b))

Output:
Greater number is 20

Program 5: Positive, Negative or Zero


Question: Write a program to positive, negative or zero.
Program:
n = -5
if n > 0:
print("Positive")
elif n < 0:
print("Negative")
else:
print("Zero")

Output:
Negative
Program 6: Print Numbers from 1 to 10
Question: Write a program to print numbers from 1 to 10.
Program:
for i in range(1, 11):
print(i)

Output:
1 2 3 4 5 6 7 8 9 10

Program 7: Sum of First 10 Natural Numbers


Question: Write a program to sum of first 10 natural numbers.
Program:
s = 0
for i in range(1, 11):
s += i
print("Sum =", s)

Output:
Sum = 55

Program 8: Factorial of a Number


Question: Write a program to factorial of a number.
Program:
n = 5
fact = 1
for i in range(1, n+1):
fact *= i
print("Factorial =", fact)

Output:
Factorial = 120

Program 9: Reverse a Number


Question: Write a program to reverse a number.
Program:
n = 123
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n //= 10
print("Reverse =", rev)

Output:
Reverse = 321

Program 10: Palindrome Number


Question: Write a program to palindrome number.
Program:
n = 121
temp = n
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n //= 10
if temp == rev:
print("Palindrome")
else:
print("Not Palindrome")

Output:
Palindrome

You might also like