Chapter 7 Quiz

¡Supera tus tareas y exámenes ahora con Quizwiz!

def main(): a = 2 b = 5 function1(b, y=a)def function1(x, y):print(x, y)main() What is the output? A. 5 2 B. 2 5 C.error message D. None of the above

A. 5 2

def main():a = 2 b = 5 function1(b)def function1(x, y=2):print(x, y)main() What is the output? A. 5 2 B. 2 5 C. No output due to syntax error D. None of the above

A. 5 2

def main():a = 2 b = 5 function1(x=b, y=a)def function1(x, y):print(x, y)main() What is the output? A. 5 2 B. 2 5 C. error message D. None of the above

A. 5 2

Which of the following about main function in Python is true? A. It is typically used to implement the mainline logic of the program B. Every Python program must have a main function C. No statement is needed in a Python program to invoke the main function

A. It is typically used to implement the mainline logic of the program

Given the definition of the function print_dotted_line: def print_dotted_line():print(".....") Which of the following statements will invoke the function print_dotted_line successfully? A. print_dotted_line B. print_dotted_line() C. print_dotted_line(): D. def print_dotted_line()

B. print_dotted_line()

Which of the following function definition has no syntax error? Selected Answer:C. def print_dotted_line(): print(".....") A. def print_dotted_line: print(".....") B. def print_dotted_line() print(".....") C. def print_dotted_line(): print(".....") D. print_dotted_line(): print(".....")

C. def print_dotted_line: print(".....")

emp_name = input("Enter employee's name: ")emp_age = int(input("Enter employee's age: "))show_info(emp_name, emp_age) Which of the following functions will correctly display name and age entered by the user? A. def show_info(): print('Name:', emp_name, ' Age:', emp_age) B. def show_info(age, name): print('Name:', name, ' Age:', age) C. def show_info(name, age): print('Name:', name, ' Age:', age) D. None of the above

C. def show_info(name, age): print('Name:', name, ' Age:', age)

def main(): a = 2 b = 5 function1(x=b, a)def function1(x, y):print(x, y)main() What is the output? A. 5 2 B. 2 5 C. error message D. None of the above

C. error message

Given the definition of the function one_year_older: def one_year_older(name, age): print('Name:', name) age = age + 1 print('Your age next year:', age) print() Which of the following statements will invoke the function one_year_older successfully? A. one_year_older(27, 'John') B. one_year_older() C. one_year_older('John', 27) D. one_year_older('John')one_year_older(27)

C. one_year_older('John', 27)

Which of the following about Python functions is true? A function is a named group of program statements performing some tasks B. The code that makes up a function is called function definition C. Function definition includes two parts: function header and function body D. All of the above

D. All of the above


Conjuntos de estudio relacionados

Life Insurance Policies & Annuities TEST

View Set

Perry Ch 7-10 Practice Questions

View Set

Collocations #1 Which One Word Fits All Three Sentences

View Set

NUR 306: Vsim Carla Hernandez Pre/Post-test

View Set

Unit 2: Psychology - How can colors be useful?

View Set

Traduccion: Terminos y conceptos basicos (SPAN 341)

View Set

Key Terms for Rational & Irrational Numbers

View Set

Physical Assessment preassessment

View Set