Table of Contents
Get All Weeks Programming in Python Coursera Quiz Answers
Week 1: Programming in Python Coursera Quiz Answers
Quiz 1: Knowledge check – Welcome to Python Programming
Question 1: Is a string in Python a sequence?
Question 2: In Python, what symbol is used for comments in code?
ViewQuestion 3: What type will be assigned to the following variable: x = 4?
ViewQuestion 4: Python allows for both implicit and explicit data type conversions?
ViewQuestion 5: A variable called name is assigned the value of “Testing”. What will the output of the following equal – print(len(name));
ViewQuiz 2: Self-review: Use control flow and loops to solve a problem
Question 1: Python for loops works on any type of sequence data type including strings.
ViewQuestion 2: The enumerate function is used to provide the index of the current iteration of a for a loop.
ViewQuestion 3: A break statement can be used to exit out of a for loop based on a certain condition being satisfied.
ViewQuiz 3: Module quiz: Getting Started with Python
Question 1: Python is a dynamically typed language. What does this mean?
ViewQuestion 2: How do you create a block in Python?
ViewQuestion 3: When declaring a variable in Python, can a variable name contain white space?
ViewQuestion 4: How can a variable be deleted in python?
ViewQuestion 5: In Python, how can you convert a number to a string?
ViewQuestion 6: An Integer – int in Python can be converted to type Float by using the float function?
ViewQuestion 7: What is the purpose of a break in a for loop in Python?
View.
Question 8: An enumerate function is used to provide the index of the current iteration of a for loop.
ViewQuestion 9: What will be the output of the code below:
a = isinstance(str, “aa”)
print(a)
ViewQuestion 10: Select all the valid input() formats among the following.
Select all that apply
View2.name = input(“What is your name? “)
Week 2: Programming in Python Coursera Quiz Answers
Quiz 1: Functions, loops and data structures
Question 1: What keyword is used to create a function in Python?
ViewQuestion 2: What function in Python allows you to output data onto the screen?
ViewQuestion 3: A variable that is declared inside a function cannot be accessed from outside the function?
ViewQuestion 4: Which of the declarations is correct when creating a for loop?
ViewQuestion 5: What error will be thrown from the below code snippet?
Viewnums = 34
for i in nums:
print(i)
Quiz 2: Knowledge check: Functions and Data structures
Question 1: The scope inside a function is referred to as?
ViewQuestion 2: Given the below list, what will be the output of the print statement be?
Viewlist_items = [10, 22, 45, 67, 90]
print(list_items[2])
Question 3: Which data structure type would be most suited for storing information that should not change?
ViewQuestion 4: Which of the options below is not considered a built-in Python data structure?
ViewQuestion 5: A Set in Python does not allow duplicate values?
ViewQuiz 3: Exceptions in Python
Question 1: : What type of specific error will be raised when a file is not found?
ViewQuestion 2: Which of the following keywords are used to handle an exception?
ViewQuestion 3: Which of the following is the base class for all user-defined exceptions in Python?
ViewQuiz 4: Read in data, store, manipulate and output new data to a file
Question 1: What function allows reading and writing files in Python?
ViewQuestion 2: Which method allows reading of only a single line of a file containing multiple lines?
ViewQuestion 3: What is the default mode for opening a file in python?
ViewQuestion 4: What is the difference between write and append mode?
ViewQuestion 5: What error is returned if a file does not exist?
ViewQuiz 5: Module quiz: Basic Programming with Python
Question 1: Which of the following is not a sequence data-type in Python?
ViewQuestion 2: For a given list called new_list, which of the following options will work:
new_list = [1,2,3,4]
Select all that apply.
View2.new_list.insert(0, 0)
3.new_list.append(5)
Question 3: Which of the following is not a type of variable scope in Python?
ViewQuestion 4: Which of the following is a built-in data structure in Python?
ViewQuestion 5: For a given file called ‘names.txt’, which of the following is NOT a valid syntax for opening a file:
ViewQuestion 6: Which among the following is not a valid Exception in Python?
ViewQuestion 7: For a file called name.txt containing the lines below:
View[‘First line\n’,
‘Second line\n’,
‘And another !’] [‘First line’] First line’ [‘First line’] ‘First line’
‘Second line’
‘And another !’
First line
Second line
And another !
with open('names.txt', 'r') as file:
lines = file.readlines()
print(lines)
Question 8: State TRUE or FALSE:
*args passed to the functions can accept the key-value pair.
ViewWeek 3: Programming in Python Coursera Quiz Answers
Quiz 1: Self-review: Make a cup of coffee
Question 1: True or False: While writing pseudocodes, we ideally put instructions for commands on the same line.
ViewQuestion 2: What variable type would be best suited for determining if the kettle was boiling?
ViewQuestion 3: Assuming milk and sugar are booleans and both are True. What conditional statement is correct for a user who wants both milk and sugar in their coffee?
ViewQuiz 2: Knowledge check: Procedural Programming
Question 1: Which of the algorithm types below finds the best solution in each and every step instead of being overall optimal?
ViewQuestion 2: Which of the following Big O notations for function types has the slowest time complexity?
ViewQuestion 3: True or False: Linear time algorithms will always run under the same time and space regardless of the size of input.
ViewQuestion 4: For determining efficiency, which of the following factors must be considered important?
ViewQuiz 3: Mapping key values to dictionary data structures
Question 1: What will be the output of the following code:
a = [[96], [69]]
print(”.join(list(map(str, a))))
ViewQuestion 2: Which of the following is TRUE about the map() and filter() functions?
ViewQuestion 3: What will be the output of the following code:
Viewz = ["alpha","bravo","charlie"]
new_z = [i[0]*2for i in z]
print(new_z)
Quiz 4: Knowledge check: Functional Programming
Question 1:
def sum(n):
if n == 1:
return 0
return n + sum(n-1)
a = sum(5)
print(a)
What will be the output of the recursive code above?
RecursionError: maximum recursion depth exceeded
ViewQuestion 2: Statement A: A function in Python only executes when called.
Statement B: Functions in Python always returns a value.
ViewQuestion 3:
some = ["aaa", "bbb"]
#1
def aa(some):
return
#2
def aa(some, 5):
return
#3
def aa():
return
#4
def aa():
return "aaa"
Which of the above are valid functions in Python? (Select all that apply)
View2.1
3.3
Question 4: For the following code:
numbers = [15, 30, 47, 82, 95]
def lesser(numbers):
return numbers < 50
small = list(filter(lesser, numbers))
print(small)
If you modify the code above and change filter() function to map() function, what will be the list elements in the output that were not there earlier?
ViewQuiz 5: Self-review: Define a Class
Question 1: Which of the following can be used for commenting a piece of code in Python?
Select all the correct answers.
View2.(‘’’ ‘’’) – Triple quotations
Question 2: What will be the output of running the following code:
Viewvalue = 7
class A:
value = 5
a = A()
a.value = 3
print(value)
Question 3: What will be the output of the following code:
Viewbravo = 3
b = B()
class B:
bravo = 5
print("Inside class B")
c = B()
print(b.bravo)
Question 4: Which of the following keywords allows the program to continue execution without impacting any functionality or flow?
ViewQuiz 6: Self-review: Instantiate a custom Object
Question 1: Were you able to complete the code and get the expected final output mentioned?
ViewQuestion 2: What was the part that you were not able to complete? Specify the line numbers in the 8 lines of code.
The expected code for the program is as follows:
View6
8
3
None
7
1
2
4
class MyFirstClass():
print("Who wrote this?")
index = "Author-Book"
def hand_list(self, philosopher, book):
print(MyFirstClass.index)
print(philosopher + " wrote the book: " + book)
whodunnit = MyFirstClass()
whodunnit.hand_list("Sun Tzu", "The Art of War")
Question 3: Which of the following is the class variable in the code above?
ViewQuestion 4: How will you modify the code below if you want to include a “year” of publication in the output?
Viewdef hand_list(self, philosopher, book, year):
print(philosopher + ” wrote the book: ” + book + “in the year ” + year)
whodunnit.hand_list(“Sun Tzu”, “The Art of War”, “5th century BC”)
class MyFirstClass():
print("Who wrote this?")
index = "Author-Book"
def hand_list(self, philosopher, book):
print(MyFirstClass.index)
print(philosopher + " wrote the book: " + book)
whodunnit = MyFirstClass()
whodunnit.hand_list("Sun Tzu", "The Art of War")
Quiz 7: Abstract classes and methods
Question 1: Which of the following is not a requirement to create an abstract method in Python?
ViewQuestion 2: There is a direct implementation of Abstraction in Python.
ViewQuestion 3: Which OOP principle is majorly used by Python to perform Abstraction?
ViewQuestion 4: Which of the following statements about abstract classes is true?
ViewQuestion 5: True or False: Abstract classes cannot exist without Abstract methods present inside them.
ViewQuiz 8: Self-review: Working with Methods
Question 1: True or False: A class can serve as a base class for many derived classes.
ViewQuestion 2: In case of multiple inheritance where C is a derived class inheriting from both class A and B, and where a and b are the respective objects for these classes, which of the following code will inherit the classes A and B correctly? (Select all that apply)
View2.class C(A, B)
Question 3: In Example 3 of the previous exercise, if we had modified the code to include a global variable ‘a = 5’ as follows:
a = 5
class A:
a = 7
pass
class B(A):
pass
class C(B):
pass
c = C()
print(c.a())
Will the code work and what will be the output if it does?
ViewQuestion 4: What function can be used other than mro() to see the way classes are inherited in a given piece of code?
ViewQuestion 5: The super() function is used to? (Select all that apply)
View2.called over the __init__() method of the class it is called from
Question 6: What is the type of inheritance in the code below:
Viewclass A():
pass
class B(A):
pass
class C(B):
pass
Quiz 9: Module quiz: Programming Paradigms
Question 1: Which of the following can be used for commenting a piece of code in Python?
View2.· ( # ) – Hashtag *
Question 2: What will be the output of running the following code?
Viewvalue = 7
class A:
value = 5
a = A()
a.value = 3
print(value)
Question 3: What will be the output of running the following code?
Viewbravo = 3
b = B()
class B:
bravo = 5
print("Inside class B")
c = B()
print(b.bravo)
Question 4: Which of the following keywords allows the program to continue execution without impacting any functionality or flow?
ViewQuestion 5: Which of the following is not a measure of Algorithmic complexity?
ViewQuestion 6: Which of the following are the building blocks of Procedural programming?
ViewQuestion 7: True or False: Pure functions can modify global variables.
ViewQuestion 8: Which of the following is an advantage of recursion?
ViewWeek 4: Programming in Python Coursera Quiz Answers
Quiz 1: Knowledge check: Modules
Question 1: Assuming there exists a module called ‘numpy’ with a function called ‘shape’ inside it, which of the following is NOT a valid syntax for writing an import statement? (Select all that apply)
View2.import * from numpy
Question 2: Which of the following locations does the Python interpreter search for modules by default?
ViewQuestion 3: We can import a text file using the import statement in Python:
ViewQuestion 4: Which of the following statements is NOT true about the reload() function?
ViewQuestion 5: Which of the following is NOT to be considered as an advantage of modular programming while using Python?
ViewQuestion 6: Which of the following module types are directly available for import without any additional installation when you begin writing our code in Python? (Select all that apply)
View2.Built-in modules
Quiz 2: Knowledge check: Popular Packages, Libraries and Frameworks
Question 1: Which of these is a popular package that is NOT primarily used in Web development?
ViewQuestion 2: Which of these packages can be applied in the field of Machine learning and Deep learning?
Select all the correct answers.
View2.Keras
3.TensorFlow
Question 3: Which of the following is not a type of web framework architecture?
ViewQuestion 4: Pandas library in Python cannot be used for which of the following tasks?
ViewQuestion 5: Which of the following is not a built-in package in the Python standard library?
ViewQuiz 3: Testing quiz
Question 1: State whether the following statement is True or False:
“Integration testing is where the application or software is tested as a whole and tested against the set requirements and expectations to ensure completeness”
ViewQuestion 2: Which of the following is NOT primarily one of the four levels in testing?
ViewQuestion 3: Which of the following can be considered a valid testing scenario? (Select all that apply.)
View2.Check for negative value acceptance in numeric field
3.If the webpage resizes appropriately according to the device in use
4.Deletion or form updation should request confirmation
Question 4: What can be considered as an ideal testing scenario?
ViewQuestion 5: Which job roles are not always a part of the testing lifecycle working on an application or product?
ViewQuiz 4: Module quiz: Modules, packages, libraries and tools
Question 1: Which of the following is not true about Test-driven development?
View2.The process can also be called Red-Green refactor cycle.
3.Test-driven development can only have one cycle of testing and error correction.
4.In TDD, the requirements and standards are highlighted from the beginning.
Question 2: Which of the following is a built-in package for testing in Python?
View2.Robot Framework
3.PyTest
4.Pyunit or Unittest
Question 3: Which of the following is an important keyword in Python used for validation while doing Unit testing?
View2.assert
3.async
4.lambda
Question 4: Which of the following ‘V’s’ is not identified as a main characteristic of Big Data?
View2.Variability
3.Volume
4.Variety
Question 5: What will be the output of the following piece of code:
View2.ImportError: No module named math
3.3.141592653589793
4.NameError: name ‘math’ is not defined
from math import pi
print(math.pi)
Question 6: Which of the following is NOT primarily a package used for Image processing or data visualization?
View2.OpenCV
3.Seaborn
4.Scrapy
Question 7: _______ is/are the default package manager(s) for installing packages in Python.
View2.pip
3.Python Standard Library
4.Built-in Module
Question 8: If you are working on some codeblock, which of the following can be ‘imported’ in it from external source?
Select all that apply.
View2.Modules
3.Packages
4.Functions
Week 5: Programming in Python Coursera Quiz Answers
Quiz: End-of-Course Graded Assessment: Using Python
Question 1: Python is an interpreted language. Which of the following statements correctly describes an interpreted language?
View2.The source code is pre-built and compiled before running.
3.The source code is converted into bytecode that is then executed by the Python virtual machine.
4.Python needs to be built prior to it being run.
Question 2: Why is indentation important in Python?
ViewQuestion 3: What will be the output of the following code?
Viewnames = ["Anna", "Natasha", "Mike"]
names.insert(2, "Xi")
print(names)
Question 4: What will be the output of the code below?
Viewfor x in range(1, 4):
print(int((str((float(x))))))
Question 5: What will be the output of the following code:
View1 2 3
sample_dict = {1: 'Coffee', 2: 'Tea', 3: 'Juice'}
for x in sample_dict:
print(x)
Question 6: What will be the output of the recursive code below?
Viewdef recursion(num):
print(num)
next = num - 3
if next > 1:
recursion(next)
recursion(11)
Question 7: What will be the type of time complexity for the following piece of code:
View- Logarithmic Time
- Constant Time
- Quadratic Time
- Linear Time
Question 8: What will be the output of the code below:
Viewstr = 'Pomodoro'
for l in str:
if l == 'o':
str = str.split()
print(str, end=", ")
Question 9: Find the output of the code below:
Viewdef d():
color = "green"
def e():
nonlocal color
color = "yellow"
e()
print("Color: " + color)
color = "red"
color = "blue"
d()
Question 10: Find the output of the code below:
Viewnum = 9
class Car:
num = 5
bathrooms = 2
def cost_evaluation(num):
num = 10
return num
class Bike():
num = 11
cost_evaluation(num)
car = Car()
bike = Bike()
car.num = 7
Car.num = 2
print(num)
Question 11: Which of the following is the correct implementation that will return True if there is a parent class P, with an object p and a sub-class called C, with an object c?
View2.print(issubclass(C,P))
3.print(issubclass(C,c))
4.print(issubclass(p,C))
Question 12: Django is a type of:
ViewQuestion 13: Which of the following is not true about Integration testing:
View2.It is where the application is tested as a whole.
3.Primarily dealt by the tester.
4.It combines unit tests.
Question 14: While using pytest for testing, it is necessary to run the file containing the main code before we can run the testing file containing our unit tests.
ViewQuestion 15: What will be the output of the code below:
Viewclass A:
def a(self):
return "Function inside A"
class B:
def a(self):
return "Function inside B"
class C:
pass
class D(C, A, B):
pass
d = D()
print(d.a())
Get All Weeks Meta Database Engineer Professional Certificate
Introduction to Databases Coursera Quiz Answers
Version Control Coursera Quiz Answers
Database Structures and Management with MySQL Quiz Answers
Advanced MySQL Topics Coursera Quiz Answers
Programming in Python Coursera Quiz Answers
Database Clients Coursera Quiz Answers
Advanced Data Modeling Coursera Quiz Answers