Intro to Python Exam Questions:Answers Graded A+
Intro to Python Exam Questions:Answers Graded A+ Why are functions helpful? - ANSWER-Functions facilitate code reusability, readability, and maintenance What is "scope" in terms of programming language python? - ANSWER-Scope is the term used to describe the points at which in code variables and functions are defined. Why is there an error when trying to run this code? a=int(input()) b=int(input()) if ca+b: print("Less than a +b:) a = b= c=1 print (a,b,c) - ANSWER-The variable c is not in scope or defined in line 3. Which of the following lines of code defines a function named "my_func" that has three parameters (a, b, and c) where b defaults to 0 and c defaults to "Yes"? a. my_func(a,b,c): b. def my_func(a, b(0), c("yes"): c. def my_func(a, b=0, c="Yes"): d. def my_func(a, b, c): - ANSWER-c Which of the following lines of code will not call a function named "my_func" that has three parameters (a, b, and c) where b defaults to 0 and c defaults to "Yes"? a.) my_func( ) b.) my_func(1, c="No") c.) my_func(1) d.) my_func(1, 2) - ANSWER-a Which of the following will import a specific function "add_numbers" from a library "adding_library"? - ANSWER-from adding_library import add_numbers import file name without the .py extension (How to import the full module/libray) from file name without the .py extension import function name
Información del documento
- Subido en
- 28 de marzo de 2024
- Número de páginas
- 23
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas