Getting Started with Python

Chapter 4 (Quiz Answers) | Week-6 | Programming for Everybody (Getting Started with Python) By Coursera

Chapter 4 (Quiz Answers) | Week-6 | Programming for Everybody (Getting Started with Python) By Coursera

Coursera
Programming for Everybody (Getting Started with Python)
Week 6
Chapter 4
Graded Quiz • 30 min


1. Which Python keyword indicates the start of a function definition?
  • sweet
  • def
  • continue
  • help

2. In Python, how do you indicate the end of the block of code that makes up the function?
  • You put the colon character (:) in the first column of a line
  • You put the “END” keyword in column 7 of the line which is to be the last line of the function
  • You de-indent a line of code to the same indent level as the def keyword
  • You add a line that has at least 10 dashes



3. In Python what is the input() feature best described as?
  • A user-defined function
  • The central processing unit
  • A built-in function
  • A conditional statement



4. What does the following code print out?
def thing():
print('Hello')
print('There')
  • thing

       Hello

       There

  • Hello
  • There
  • def

       thing




5. In the following Python code, which of the following is an “argument” to a function?
x = 'banana'
y = max(x)
z = y * 2
  • x
  • max
  • ‘banana’
  • y


6. What will the following Python code print out?
def func(x) :
print(x)
func(10)
func(20)
  • x
     x
  • x
    20
  • def
    x
    func
    func
  • 10
     20



7. Which line of the following Python program will never execute?
def stuff():
print('Hello')
return
print('World')
stuff()
  • return
  • print (‘World’)
  • def stuff():
  • print(‘Hello’)
  • stuff()


8. What will the following Python program print out?
def greet(lang):
if lang == 'es':
return 'Hola'
elif lang == 'fr':
return 'Bonjour'
else:
return 'Hello'
print(greet('fr'),'Michael')
  • Bonjour Michael
  • Hola Michael
  • Hello Michael
  • def
     Hola
     Bonjour
     Hello
     Michael




9. What does the following Python code print out? (Note that this is a bit of a trick question and the code has what many would consider to be a flaw/bug – so read carefully).
def addtwo(a, b):
added = a + b
return a
x = addtwo(2, 7)
print(x)
  • 2
  • 7
  • 14
  • 9

10. What is the most important benefit of writing your own functions?
  • Following the rule that no function can have more than 10 statements in it
  • Following the rule that whenever a program is more than 10 lines you must use a function
  • To avoid having more than 10 lines of sequential code without an indent or de-indent
  • Avoiding writing the same non-trivial code more than once in your program


The above questions are from “Programming for Everybody (Getting Started with Python)” You can discover all the refreshed questions and answers related to this on the “Programming for Everybody (Getting Started with Python) By Coursera” page. If you find the updated questions or answers, do comment on this page and let us know. We will update the answers as soon as possible.


Do Not Only Use These Quizzes For Getting Certificates.You Can Take Help From These Quizzes Answer. All Quizzes & Contents Are Free Of Charge. ✅

If You Want Any Quiz Answers Then Please Contact Us

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *