Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def print_name(first_name, last_name):
- # print(first_name)
- print('hi ' + first_name + ' ' + last_name)
- def savings(pocket_money, paper_route, spending):
- return pocket_money + paper_route - spending
- def scope_demo():
- var1 = 10
- var2 = 20
- return var1 * var2
- main_script_var = 6
- def another_scope_demo():
- var1 = 10
- var2 = 20
- return var1 * var2 - main_script_var
- def spaceship_building(cans, week_num):
- total_cans = 0
- for week in range(1, week_num + 1):
- total_cans = total_cans + cans
- print('week ' + str(week) + ': ' + str(total_cans))
- # prints out "hi kevin s" and "None" because of how returns work
- print(print_name('kevin', 's'))
- # just prints out 19
- print(savings(10, 15, 6))
- print(scope_demo())
- # print(var1) # errors because var1 is only defined in the function
- print(another_scope_demo())
- # adds 3 cans a week for 10 weeks (defined in parameters)
- spaceship_building(3, 11)
- # quick module demo
- import time
- print(time.asctime())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement