Riju21

16_str_formt_adv_ope_for_str,obj,date,dicts

Mar 27th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # obj print
  2. info = {
  3.     'name': 'Neymar',
  4.     'age': 26,
  5.     'pos': 'forwrd',
  6.     'country': 'brazil',
  7.     'club': 'psg'
  8. }
  9. # sen = 'name is: ' + info['name'] + ' ,age is: ' + str(
  10. #     info['age']) + ' ,position is: ' + info['pos'] + ' ,country: ' + info['country'] + ' ,club: ' + info['club']
  11. # print(sen)
  12. # or,
  13. # sen = 'name is: {}, age is: {}, position is: {}, country: {}, club: {}'.format(
  14. #     info['name'], info['age'], info['pos'], info['country'], info['club'])
  15. # print(sen)  
  16.  
  17.  
  18.  
  19. # class info1():
  20. #     def __init__(self, name, age):
  21. #         self.name = name,
  22. #         self.age = age
  23.  
  24. # inf = info1('neymar', '26')
  25. # res = 'name: {0.name} , age: {0.age}'. format(inf)
  26. # print(res)            
  27.  
  28.  
  29. #   number format
  30.  
  31. # py = 3.14159
  32. # res = 'pi is equal to {:.2f}'.format(py)
  33. # print(res)  
  34.  
  35. gb = 1024
  36. res = '1 gb = {:,} kb'.format(gb ** 2)
  37. print(res)
Advertisement
Add Comment
Please, Sign In to add comment