0% found this document useful (0 votes)
182 views

Unit 3 - Week 1 Quiz

This document is a quiz for a course on programming, data structures and algorithms using Python. The quiz contains 4 multiple choice questions testing concepts like functions, recursion, factors and sums.

Uploaded by

vinith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views

Unit 3 - Week 1 Quiz

This document is a quiz for a course on programming, data structures and algorithms using Python. The quiz contains 4 multiple choice questions testing concepts like functions, recursion, factors and sums.

Uploaded by

vinith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming, data structures and algorithms u... https://onlinecourses.nptel.ac.in/noc18_cs34/uni...

[email protected]

Courses » Programming, data structures and algorithms using Python

Announcements Course Ask a Question Progress Mentor FAQ

Unit 3 - Week
1 Quiz

Course
outline
Week 1 Quiz
The due date for submitting this assignment has passed.
How to access As per our records you have not submitted this Due on 2018-08-23, 23:59 IST.
the portal assignment.

Week 1: All questions carry equal weightage. All Python code is assumed to be executed using Python3. You
Introduction may submit as many times as you like within the deadline. Your final submission will be graded.

Week 1 Quiz 1) What does g(31415927) return, for the following function definition?

Quiz : Week 1 def g(x):


Quiz (q,d) = (1,0)
while q <= x:
Week 2: Basics (q,d) = (q*10,d+1)
of Python
return(d)

Week 2 Quiz

Week 2
No, the answer is incorrect.
Programming
Assignment Score: 0
Feedback:
Week 3: Lists, d is the largest power of 10 that is smaller than 31415927. In general, for non-negative inputs x, g(x) ounts
inductive the digits in x.
function
definitions, Accepted Answers:
sorting (Type: Numeric) 8

1 point
Week 3
Programming 2) What is the value of h(231,8) for the function below?
Assignment
def h(m,n):
Week 4: Sorting, ans = 0
Tuples,
while (m >= n):
Dictionaries,
Passing (ans,m) = (ans+1,m-n)
Functions, List return(ans)
Comprehension

Week 4 Quiz
© 2014 NPTEL - Privacy & Terms - Honor Code - FAQs -
A project of In association with

Funded by

1 of 3 Wednesday 17 October 2018 01:13 PM


Programming, data structures and algorithms u... https://onlinecourses.nptel.ac.in/noc18_cs34/uni...

Exception (Type: Numeric) 28 by


Powered
handling,
input/output, file 1 point
handling, string
processing 3) Consider the following function h. 1 point

def h(n):
Week 5
Programming f = 0
Assignment for i in range(1,n+1):
if n%i == 0:
Week 6: f = f + 1
Backtracking, return(f%2 == 1)
scope, data
structures; The function h(n) given above returns True for a positive number n whenever:
stacks, queues
and heaps
n is a multiple of 2

Week 6 Quiz n is a composite number

n is a prime number
Week 7: Classes,
objects and user n is a perfect square
defined
datatypes No, the answer is incorrect.
Score: 0
Week 7 Quiz
Feedback:
f is the number of factors of n between 1 and n. Factors of n occur in pairs (x,y) so that x*y = n. If n is a
Week 8:
Dynamic perfect square, one factor will be its own pair, so the number of factors is odd and f returns True. If n is not
programming, a perfect square, the number of factors is even and f returns False.
wrap-up
Accepted Answers:
n is a perfect square
Week 8
Programming 4) Consider the following function f. 1 point
Assignment
def f(m):
Text Transcripts if m == 0:
return(0)
DOWNLOAD else:
VIDEOS
return(m+f(m-1))

Which of the following is correct?

The function always terminates with f(n) = n(n+1)/2

The function always terminates with f(n) = factorial of n

The function terminates for non-negative n with f(n) = n(n+1)/2

The function terminates for non-negative n with f(n) = factorial of n

No, the answer is incorrect.


Score: 0
Feedback:
If m is negative, the function does not terminate. Otherwise, it computes 1+2+..+m = m(m+1)/2.
Accepted Answers:
The function terminates for non-negative n with f(n) = n(n+1)/2

End

2 of 3 Wednesday 17 October 2018 01:13 PM


Programming, data structures and algorithms u... https://onlinecourses.nptel.ac.in/noc18_cs34/uni...

3 of 3 Wednesday 17 October 2018 01:13 PM

You might also like