0% found this document useful (0 votes)
99 views2 pages

Class 10 Python Programs: 15 Examples

Uploaded by

niyamyadav2009
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)
99 views2 pages

Class 10 Python Programs: 15 Examples

Uploaded by

niyamyadav2009
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 10 Python Programs (15 Codes)

1. Print Hello World


print('Hello World')

2. Add two numbers


a=int(input())
b=int(input())
print(a+b)

3. Even or Odd
n=int(input())
if n%2==0: print('Even')
else: print('Odd')

4. Greatest of two numbers


a=int(input())
b=int(input())
print(a if a>b else b)

5. Greatest of three numbers


a,b,c=map(int,input().split())
print(max(a,b,c))

6. Positive Negative or Zero


n=int(input())
print('Positive' if n>0 else 'Negative' if n<0 else 'Zero')

7. 1 to 10 numbers
for i in range(1,11): print(i)

8. Sum of first 10 numbers


print(sum(range(1,11)))

9. Table of a number
n=int(input())
for i in range(1,11): print(n*i)

10. Factorial
n=int(input())
f=1
for i in range(1,n+1): f*=i
print(f)

11. Prime number


n=int(input())
c=0
for i in range(1,n+1):
if n%i==0: c+=1
print('Prime' if c==2 else 'Not Prime')

12. Reverse number


n=int(input())
r=0
while n>0:
r=r*10+n%10
n//=10
print(r)

13. Palindrome
n=int(input())
t=n
r=0
while n>0:
r=r*10+n%10
n//=10
print('Palindrome' if t==r else 'Not Palindrome')

14. Count vowels


s=input()
c=0
for i in s:
if [Link]() in 'aeiou': c+=1
print(c)

15. Simple Calculator


a=int(input())
b=int(input())
print(a+b,a-b,a*b,a/b)

You might also like