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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

 

Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education