Basic of My Pyhthon Notes

   day 12 Strings slicing suing Python

# so here we are learning about String slicing

a="Mango"

l=len(a)

print(l)

print(a[0:3])

print(a[1:3])

print(a[:5])

print(a[0:-3])#so here python automatically find out the len of string and then substract it from the string

print(a[-1:-3])#so here -(5-1)to -(5-3) i.e 4:2 not fit the proper syntax

print(a[-3:-1])#here we have -(5-3)to -(5-1) i.e 2:4

print(a[2:4])


   This This the 15th day program 

taking time and giving output as Good even night morning


import time

tstmp = time.strftime('%H:%M:%S')

print("time is ",tstmp)

tstmp = time.strftime('%H')

print("hour",tstmp)

tstmp = time.strftime('%M')

print("Minute",tstmp)

tstmp = time.strftime('%S')

print("Second is", tstmp)

t=int(time.strftime('%H'))

print("The vale of t",t)

if(23>=t<=6):

  print("Good night")

elif(t>=6 and t<=11):

  print("Good morning")

elif(12>=t<=16):

  print("Good Noon ")

else:

  print("Good Evening")








Comments