Skip to content

Commit

Permalink
manipulations with strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed May 2, 2018
1 parent a65f8a4 commit 2ea58cb
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classes/class1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class student():
name = "rakesh"
website ="binarynote.com"
expertise ="PHP, CSS, HTML,JavaScript,JQuery,WordPress and Now Python Django"

def showMessage(self):
print("This is a demo message from class ")

Expand Down
22 changes: 22 additions & 0 deletions classes/class2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class student():
name = "rakesh"
website ="binarynote.com"
expertise ="PHP, CSS, HTML,JavaScript,JQuery,WordPress and Now Python Django"

def setData(self,name,web,exp):
self.name = name
self.website = web
self.expertise = exp

def showData(self):
print("Name : ",self.name)
print("website : ", self.website)
print("Expertise :", self.expertise,"\n")

#object creation
s = student()
s.showData()

# set new Data using another function
s.setData("Swarnima", 'swarnima.com','Python, Django, CSS, JavaScript')
s.showData()
21 changes: 21 additions & 0 deletions classes/classConstructor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class student():
name=""
website=""
expertise=""

def __init__(self):
self.name ="swarnima"
self.website = "http://www.swarnima.com"
self.expertise ="Django Specialist"

def showData(self):
print("Name : ",self.name)
print("website : ", self.website)
print("Expertise :", self.expertise,"\n")

#object creation
#

s1 = student() #calling constructor
s1.showData()

9 changes: 9 additions & 0 deletions first3char.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def front3(str):
str1 = str[:3]*3
print(str1)

front3('java')
front3('Chocolate')
front3('ab')
front3('a')
front3('')
9 changes: 9 additions & 0 deletions functions/factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def factorial():
n = int(input("Enter any number "))
fact = 1
for i in range(1,n+1):
fact *= i
print("Factorial of ", n ," is :",fact)

#function call
factorial()
9 changes: 9 additions & 0 deletions functions/factorial_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def factorial(n):
fact = 1
for i in range(1,n+1):
fact *= i
print("Factorial of ", n ," is :",fact)

#function call
n = int(input("Enter any number "))
factorial(n)
10 changes: 10 additions & 0 deletions functions/recursive_factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def factorial(n):
if n==1:
return 1
else:
return n*(factorial(n-1))

#function call
n = int(input("Enter any number "))
result = factorial(n)
print("factorial of {} is {} ".format(n,result))
6 changes: 6 additions & 0 deletions string/string1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
str = "This is me rakesh"
n = len(str)
print('Length of string is : ',n)
str = str + "Hello rakesh"
print(str)
print(str[0])
6 changes: 3 additions & 3 deletions sum_digit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
a = int(input("Enter any number :")
while a!=0:
a = int(input("Enter any number :"))
sum =0
while (a!=0):
rem = a%10
sum = sum + rem
a = int(a / 10)
Expand Down

0 comments on commit 2ea58cb

Please sign in to comment.