PYTHON QUESTION 2 MULTIPLE CHOICE A. Refer to Code Example 4-1 : What is the scope of the variable named s ? a. global b. local c. global in main() but local in get_username() d. local in main() but...


PYTHON



QUESTION 2 MULTIPLE CHOICE



A.    Refer to
Code Example 4-1: What is the scope of the variable named
s
?






















a.



global



b.



local



c.



global in main() but local in get_username()



d.



local in main() but global in get_username()






Code Example 4-4




def multiply(num1, num2):



    product = num1 * num2



    result = add(product, product)



    return result




def add(x, y):



    z = x + y



    return z




def main():



    num1 = 4



    num2 = 3



    answer = multiply(num1, num2)



    print("The answer is", answer)




    main()




B.  Refer to
Code Example 4-4: What values are in
x
and
y
after the code runs?


















a.



4, 3



c.



12, 12



b.



5, 6



d.



24, 24






C.  Refer to
Code Example 4-4: What is the value of
result?


















a.



48



c.



96



b.



24



d.



12






D.  When writing data into a file:
file1 = open (“writehere.txt” , ”w”)
, if
writehere.txt
does not exist:


















a.



the program crashes



a.



A new file named writehere.txt is created



b.



an exception is thrown but the program doesn’t crash



b.



A new file names writehere.txt is created with default data.






Code Example 5-4




with open("members.txt") as file:



    members = file.readlines();



    print(members[0], end="")



    print(members[1])




E.  Refer to
Code Example 5-4 ,
it shows:


















a.



How to read a list into file



c.



How to read the first and second chars into a file



b.



How to read file into a list



d.



How to read a file into a list with \n





Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here