Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- score=0 # score is outside of the stage 1 and stage 2 functions
- def welcome():
- name=input("Enter name: ")# NAME is a local variable it is only available in WELCOME function
- def stage1():
- global score # the global keyword makes the score available in the STAGE 1 function
- answer=input("The keyword used to make outside variables available in a function").upper()
- if answer=="GLOBAL":
- print ("Correct")
- score+=1
- else:
- print ("Wrong the answer is global")
- stage2()
- def stage2():
- global score # the global keyword makes the score available in the STAGE 2 function
- answer=input("'_____ Variable' The type of variable only available in a function").upper()
- if answer=="LOCAL":
- print ("Correct")
- score+=1
- else:
- print ("Wrong the answer is LOCAL variable")
- stage1()
- print (name) # this will not print as name is only available in the WELCOME function.
- print ("Your score is", score) # the score will be updated depending on the answers in stage 1 & 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement