word=str(raw_input('Enter the string:'))
n=raw_input('Enter the character to search in string:')
c=0
for i in word:
if i==n:
c=c+1
print 'Number of times the character repeated is', c
Solve Problems by Coding Solutions - A Complete solution for python programming
To check a string is palidrome or not
k=raw_input('Enter a string: ')
if k==k[::-1]:
print 'String is palidrome'
else:
print 'String is not palidrome'
if k==k[::-1]:
print 'String is palidrome'
else:
print 'String is not palidrome'
Find the Armstrong Number upto a number
# Compatible in Python 2.7
k=int(raw_input('Enter the range of number:'))
for n in range(k):
sum=0
temp=n
y=len(str(n))
while(n>0):
R=n%10
V=R**y
sum=sum+V
n=n/10
if (sum==temp):
print 'Armstrong Number',temp
k=int(raw_input('Enter the range of number:'))
for n in range(k):
sum=0
temp=n
y=len(str(n))
while(n>0):
R=n%10
V=R**y
sum=sum+V
n=n/10
if (sum==temp):
print 'Armstrong Number',temp
Fibonacci sequence using functions for N numbers
# Compatible in Python 2.7
def recur_fibo(n):
if n <= 1:
return n
else:
return(recur_fibo(n-1) + recur_fibo(n-2))
nterms = int(input("How many terms? "))
if nterms <= 0:
print "Plese enter a positive integer"
else:
print "Fibonacci sequence:"
for i in range(nterms):
print recur_fibo(i)
Multiplication Table
# Compatible in Python 2.7
num = int(raw_input("Display multiplication table of? "))
for i in range(1, 21):
print num,'x',i,'=',num*i
num = int(raw_input("Display multiplication table of? "))
for i in range(1, 21):
print num,'x',i,'=',num*i
Program to check the number is palindrome
# Compatible in Python 2.7
Number = int(raw_input("Please Enter any Number: "))
Temp=Number # Number is stored to a temporary variable
Reverse = 0 # Initialize the reverse value to overcome garbage value storage
if Number<0:
print 'Number is negative'
elif Number ==0:
print 'Reverse Number is',Number
elif Number>0:
while(Number > 0):
Reminder = Number %10
Reverse = (Reverse *10) + Reminder
Number = Number /10
print 'Reverse of a Number is',Reverse
else:
exit()
if Temp==Reverse:
print 'The number is palidrome'
else:
print 'The number is not palidrome'
Number = int(raw_input("Please Enter any Number: "))
Temp=Number # Number is stored to a temporary variable
Reverse = 0 # Initialize the reverse value to overcome garbage value storage
if Number<0:
print 'Number is negative'
elif Number ==0:
print 'Reverse Number is',Number
elif Number>0:
while(Number > 0):
Reminder = Number %10
Reverse = (Reverse *10) + Reminder
Number = Number /10
print 'Reverse of a Number is',Reverse
else:
exit()
if Temp==Reverse:
print 'The number is palidrome'
else:
print 'The number is not palidrome'
Python Coding Sites
Try Python http://campus.codeschool.com/courses/try-python/contents
Python Codecademy https://www.codecademy.com/learn/python
Learn Python http://www.learnpython.org/
Python Codecademy https://www.codecademy.com/learn/python
Learn Python http://www.learnpython.org/
Python Conferences on August 2016
PyCon Australia 2016
12 Aug. – 17 Aug. Melbourne Convention and Exhibition Centre, 1 Convention Centre Pl, South Wharf VIC 3006, Australia
PyCon APAC 2016
13 Aug. – 16 Aug. Trade Center COEX Samseong 1-dong Gangnam-gu, Seoul, South Korea
PyBay 2016
19 Aug. – 22 Aug. UCSF Mission Bay Conference Center, 1675 Owens St., San Francisco, CA 94143, USA
EuroScipy 2016
23 Aug. – 28 Aug. Faculty of Medicine of the University of Erlangen, Germany
PyCon MY 2016
26 Aug. – 29 Aug. City Campus of the International University of Malaya-Wales (IUMW), Kuala Lumpur, Malaysia
Values and types used in python
>>> n=1,00,000 First example we have seen of a semantic error
>>> n
(1, 0, 0)
>>> n=12 Integer
>>> n
12
>>> n="hello" String
>>> n
'hello'
>>> n=" Welcome to show" Sentence
>>> n
' Welcome to show'
>>> n=3.12 Floating Number
>>> n
3.12
Welcome Everyone for the world of Python
Python is a fourth generation programming language. Guido van Rossum is the creator of Python. Here we discuss python from the basis to the expert level required for a engineer.
Subscribe to:
Posts (Atom)