Riju21

1_begin

Mar 27th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. py = "python & python"
  2.  
  3. welcome = 'welcome'
  4.  
  5. # the way of string concat
  6.  
  7. print( 'concat: '+ py + ( ' is the most powerful language' ) )  
  8.  
  9.  
  10. # find the length
  11.  
  12. len = str( len( py ) )   # convert int to string
  13.  
  14. print( 'length: the length of python is: ' + len )
  15.  
  16. # get the characters
  17.  
  18. print( '0 to 5 elements are in python: ' + py[ 0 : 5 ] )
  19.  
  20. # or print( '0 to 5 elements are in python: ' + py[ : 5 ] )
  21.  
  22. # uppercase,lowercase
  23.  
  24. print( 'In uppercase: in uppercase python is: ' + py.upper() )
  25.  
  26. # find the number of words or chars
  27.  
  28. print( 'Count: there are: '+ str( py.count('python') ) + ' times' )
  29.  
  30. # replace
  31.  
  32. repl = py.replace('& python', '')
  33. print( 'replace: ' + repl +  ' is the most powerful language' )  
  34. # more at code no. 56
  35.  
  36. #format
  37.  
  38. formatt = '{} to {}'.format(welcome,py)
  39. print('format: ' + formatt)
  40.  
  41. # help
  42.  
  43. # print( help(str) )
  44.  
  45. # debug ctrl+F5
Advertisement
Add Comment
Please, Sign In to add comment