Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # types
- # variables
- # functions / methods
- # classes
- # TYPES
- 'hello world' # string
- "hello world" # string
- "59873" # string
- 59873 # number / integer
- 59873.54 # number / float
- "2" + "2" # "44"
- 2 + 2 # 4
- # VARIABLES
- bar = 5
- gaz = "5"
- bar * 3 # 15
- gaz + 'hi' # 5hi
- foo = "hello world 1"
- print(foo) # hello world 1
- foo = 'hello world 2'
- print(foo) # hello world 2
- foo2 = 'hello world 3'
- print(foo) # hello world 2
- print(foo2) # hello world 3
- # FUNCTIONS
- def do_nothing():
- print('ok')
- def get_circumference(radius):
- pi = 3.14
- some_constant = radius + 2
- another_constant = radius + 9
- circumference = 2 * radius * pi * some_constant * another_constant
- return circumference
- radius1 = 8
- radius2 = 9
- radius3 = 11
- radius4 = 14
- circumference1 = get_circumference(radius1) # get_circumference is a function that takes 1 argument and returns 1 thing
- circumference2 = get_circumference(radius2)
- circumference3 = get_circumference(radius3)
- circumference4 = get_circumference(radius4)
- do_nothing() # do_nothing is a function that takes 0 arguments and returns 0 things
- print('hi') # print is a function that takes 1 argument and returns 0 things
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement