Find the best solutions to your questions at Westonci.ca, the premier Q&A platform with a community of knowledgeable experts. Explore in-depth answers to your questions from a knowledgeable community of experts across different fields. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
Sagot :
Answer:
1.) 25 ; 15 ; 15
2.) 50 ; 15 ; 50
Explanation:
In the first function written :
The variable val was initially decaled or assigned a value of 25 and that was what was printed first.
However, after the example function was written, the val variable was finally assiagned a value of 15 within the function. However, it was also declared that the global variable takes uonthe val value. Hence, the val variable initially assigned a value, of 25 changes to 15 globally.
For the second code :
From the top:
Val was assigned a value of 50 ;
Hence,
print(val) gives an output of 50
Within the function definition which prints the value of val that is assigned a value of 25 within the function.
Since tbe global variable isnt reset.
Printing Val again outputs 50;since ito is outside the function.
The code output description can be defined as follows:
Code Explanation:
- In the first code, a "val" variable is declared that hold an integer value.
- In the next step, a method "example" is defined.
- Inside the method a global keyword is used that define a variable "val" in which it hold an integer value and print its value.
- After defining a method two print method is used that print "val" variable value and call exmaple method.
- In the second code, a "val" variable is declared that hold an integer value.
- In the next step, a method "example" is defined.
- Inside the method another variable "val" is defined in which it hold an integer value and print its value.
- After defining a method two print method is used that print "val" variable value and call exmaple method.
Code:
val = 25 #defining a variable val that holds an integer value
def example(): #defining a method example
global val #using keyword global to define variable val
val = 15#defining an integer variable that hold integer value
print (val)#print global variable value
print (val) #print val variable value
example()#calling example method
print (val)#print global variable value
print("----------------------------------------------------")
val = 50 #defining a variable val that holds an integer value
def example(): #defining a method example
val = 15 #define variable val that holds integer value
print(val)#print val variable value
print (val) #print val variable value
example() #calling method example
print (val)#print val value
Output:
Please find the attached file.
Learn more:
brainly.com/question/21866333
Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.