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

XII - Chap-6 - BB - Hands On Exp Prog

Cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

XII - Chap-6 - BB - Hands On Exp Prog

Cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

XII-Chapter-6-Book back-Hands on Experience programs

1.# to check if the letter is vowel or not


ch=input ("Enter a character :")
if ch in ('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'):
print (ch, 'is a vowel')
else:
print (ch, 'is a not vowel')
2.# to check the smallest number of three numbers
A=int (input("Enter first number :"))
B=int (input("Enter second number :"))
C=int (input("Enter third number :"))
if (A<B)&(A<C):
print (" A is the smallest number ")
elif (B<A)&(B<C):
print (" B is the smallest number ")
else:
print (" C is the smallest number ")
3. #to check if a number is Positive,Negative or Zero
A=int (input("Enter a number :"))
if (A>0):
print (" Given number is positive ")
elif (A<0):
print (" Given number is negative ")
else:
print (" Given number is Zero ")
4.#to display Fibonacci series 0 1 1 2 3 5 8…..(upto n terms)
n=int(input("Enter the number of Fibonacci series to be calculated:"))
i=1
f0=-1
f1=1
while(i<=n):
f=f0+f1
f0=f1
f1=f
i=i+1
print(f,end='\t')
5.#to display sum of natural numbers,upto n.
n=int(input("Enter the number:"))
n=n*(n+1)/2
print(n,end="")
6.# to check if the given number is a palindrome or not
num=int(input("Enter a number:"))
fwd=num
rev=0
while(num>0):
digit=num%10
rev=rev*10+digit
num=num//10
if(fwd==rev):
print("The given number is palindrome")
else:
print("The given number is not palindrome")

# to check if the given string is a palindrome or not


string=input("Enter the string:")
if(string==string[::-1]):
print("The string is palindrome")
else:
print("The string is not palindrome")

7.# write the program to print the following pattern


*****
****
***
**
*
i=6
while(1<=i):
for j in range(1,i):
print("*",end='\t')
print(end='\n')
i-=1

8.# to check if the given year is leap year or not


year = int(input("Enter the year :"))
if(year%4==0):
print ("Given year is a Leap year")
else:
print ("Given year is not a Leap year")

You might also like