Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. # types
  2. # variables
  3. # functions / methods
  4. # classes
  5.  
  6. # TYPES
  7.  
  8. 'hello world' # string
  9. "hello world" # string
  10. "59873" # string
  11. 59873 # number / integer
  12. 59873.54 # number / float
  13.  
  14.  
  15. "2" + "2" # "44"
  16. 2 + 2 # 4
  17.  
  18.  
  19. # VARIABLES
  20.  
  21. bar = 5
  22. gaz = "5"
  23.  
  24. bar * 3 # 15
  25. gaz + 'hi' # 5hi
  26.  
  27. foo = "hello world 1"
  28. print(foo) # hello world 1
  29. foo = 'hello world 2'
  30. print(foo) # hello world 2
  31. foo2 = 'hello world 3'
  32. print(foo) # hello world 2
  33. print(foo2) # hello world 3
  34.  
  35.  
  36. # FUNCTIONS
  37.  
  38. def do_nothing():
  39. print('ok')
  40.  
  41. def get_circumference(radius):
  42. pi = 3.14
  43. some_constant = radius + 2
  44. another_constant = radius + 9
  45. circumference = 2 * radius * pi * some_constant * another_constant
  46. return circumference
  47.  
  48. radius1 = 8
  49. radius2 = 9
  50. radius3 = 11
  51. radius4 = 14
  52.  
  53. circumference1 = get_circumference(radius1) # get_circumference is a function that takes 1 argument and returns 1 thing
  54. circumference2 = get_circumference(radius2)
  55. circumference3 = get_circumference(radius3)
  56. circumference4 = get_circumference(radius4)
  57.  
  58. do_nothing() # do_nothing is a function that takes 0 arguments and returns 0 things
  59.  
  60. print('hi') # print is a function that takes 1 argument and returns 0 things
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement