02/07/2020 The Joy of Computing using Python - Course
([Link] ([Link]
reviewer4@[Link]
NPTEL ([Link] » The Joy of Computing using Python (course)
Announcements (announcements)
About the Course ([Link] Ask a Question (forum)
Progress (student/home) Mentor (student/mentor)
Programming Assignment-1: Digits
Course Due on 2020-02-27, 23:59 IST
outline
You are given a number A which contains only digits 0's and 1's. Your task is to
make all digits same by just flipping one digit (i.e. 0 to 1 or 1 to 0 ) only. If it is
How does an possible to make all the digits same by just flipping one digit then print 'YES'
NPTEL online else print 'NO'.
course work?
Input Format:
Week 0
The first line contains a number made up of 0's and 1's.
Week 1
Output Format:
Week 2
Print 'YES' or 'NO' accordingly without quotes.
Week 3
Example:
week 4
Input:
Practice is the
key (unit?
101
unit=59&lesson=60)
Magic Square: Output:
Hit and Trial 01 YES
(unit?
unit=59&lesson=61)
Explanation:
Magic Square: If you flip the middle digit from 0 to 1 then all the digits will become same.
Hit and Trial 02 Hence output is YES.
(unit?
unit=59&lesson=62) Sample Test Cases
Input Output
Magic Square:
Hit and Trial 03 Test Case 1 0 YES
[Link] 1/4
02/07/2020 The Joy of Computing using Python - Course
(unit?
unit=59&lesson=63) Test Case 2 101010 NO
Magic Square:
Test Case 3 1101 YES
Hit and Trial 04
(unit?
unit=59&lesson=64) Test Case 4 10 YES
Magic Square:
Hit and Trial 05 Test Case 5 1011 YES
(unit?
unit=59&lesson=65) Test Case 6 0011 NO
Let's program
and play (unit?
The due date for submitting this assignment has passed.
unit=59&lesson=66)
As per our records you have not submitted this assignment.
Dobble Game - Sample solutions (Provided by instructor)
Spot the 1 A = input()
similarity 01 2 ls = []
(unit? 3 li = str(A)
4 for j in li:
unit=59&lesson=67) 5 [Link](int(j))
6 count_z = 0
Dobble Game - 7 count_o = 0
Spot the 8 for k in ls:
9 if(k==1):
similarity 02 10 count_o += 1
(unit? 11 if(k==0):
unit=59&lesson=68) 12 count_z += 1
13
14 if((count_o == 1) or (count_z == 1)):
Dobble Game - 15 print("YES")
Spot the 16
similarity 03 17 else:
18 if((count_o == 0) or (count_z == 0)):
(unit? 19 print("NO")
unit=59&lesson=69) 20 else:
21 print("NO")
Dobble Game -
Spot the
similarity 04
(unit?
unit=59&lesson=70)
What is your
date of birth?
(unit?
unit=59&lesson=71)
Birthday
Paradox - Find
your twin 01
(unit?
unit=59&lesson=72)
Birthday
Paradox - Find
your twin 02
(unit?
unit=59&lesson=73)
Birthday
Paradox - Find
your twin 03
(unit?
unit=59&lesson=74)
[Link] 2/4
02/07/2020 The Joy of Computing using Python - Course
Birthday
Paradox - Find
your twin 04
(unit?
unit=59&lesson=75)
Birthday
Paradox - Find
your twin 05
(unit?
unit=59&lesson=76)
What's your
favourite
movie? (unit?
unit=59&lesson=77)
Guess the
Movie Name
01 (unit?
unit=59&lesson=78)
Guess the
Movie Name
02 (unit?
unit=59&lesson=79)
Guess the
Movie Name
03 (unit?
unit=59&lesson=80)
Guess the
Movie Name
04 (unit?
unit=59&lesson=81)
Guess the
Movie Name
05 (unit?
unit=59&lesson=82)
Guess the
Movie Name
06 (unit?
unit=59&lesson=83)
Quiz :
Assignment 4
(assessment?
name=263)
Programming
Assignment-
1: Digits
(/noc20_cs35/progassignment?
name=280)
Programming
Assignment-2:
Factorial
(/noc20_cs35/progassignment?
name=281)
[Link] 3/4
02/07/2020 The Joy of Computing using Python - Course
Programming
Assignment-3:
Matrix
(/noc20_cs35/progassignment?
name=282)
Week 4
Feedback
(unit?
unit=59&lesson=283)
Week 5
Week 6
Week 7
Week 8
Week 9
Week 10
Week 11
Week 12
Text Transcripts
Download
Videos
Books
[Link] 4/4
02/07/2020 The Joy of Computing using Python - Course
([Link] ([Link]
reviewer4@[Link]
NPTEL ([Link] » The Joy of Computing using Python (course)
Announcements (announcements)
About the Course ([Link] Ask a Question (forum)
Progress (student/home) Mentor (student/mentor)
Programming Assignment-2: Factorial
Course Due on 2020-02-27, 23:59 IST
outline
Given an integer number n, you have to print the factorial of this number. To
know about factorial please click on this link
How does an ([Link]
NPTEL online
course work? Input Format:
Week 0 A number n.
Week 1 Output Format:
Week 2 Print the factorial of n.
Week 3 Example:
week 4 Input:
4
Practice is the
key (unit?
Output:
unit=59&lesson=60)
24
Magic Square:
Hit and Trial 01 Sample Test Cases
(unit? Input Output
unit=59&lesson=61)
Test Case 1 8 40320
Magic Square:
Hit and Trial 02
Test Case 2 7 5040
(unit?
unit=59&lesson=62)
Test Case 3 10 3628800
Magic Square:
Hit and Trial 03
[Link] 1/4
02/07/2020 The Joy of Computing using Python - Course
(unit?
unit=59&lesson=63) Test Case 4 5 120
Magic Square:
Test Case 5 4 24
Hit and Trial 04
(unit?
unit=59&lesson=64) Test Case 6 6 720
Magic Square:
Hit and Trial 05 The due date for submitting this assignment has passed.
(unit?
As per our records you have not submitted this assignment.
unit=59&lesson=65)
Sample solutions (Provided by instructor)
Let's program 1 k = int(input())
and play (unit? 2
3 fac = 1
unit=59&lesson=66) 4 for i in range(1,k+1):
5 if(k==0):
Dobble Game - 6 break
Spot the 7 fac=fac*i
8
similarity 01 9 print(fac)
(unit?
unit=59&lesson=67)
Dobble Game -
Spot the
similarity 02
(unit?
unit=59&lesson=68)
Dobble Game -
Spot the
similarity 03
(unit?
unit=59&lesson=69)
Dobble Game -
Spot the
similarity 04
(unit?
unit=59&lesson=70)
What is your
date of birth?
(unit?
unit=59&lesson=71)
Birthday
Paradox - Find
your twin 01
(unit?
unit=59&lesson=72)
Birthday
Paradox - Find
your twin 02
(unit?
unit=59&lesson=73)
Birthday
Paradox - Find
your twin 03
(unit?
unit=59&lesson=74)
[Link] 2/4
02/07/2020 The Joy of Computing using Python - Course
Birthday
Paradox - Find
your twin 04
(unit?
unit=59&lesson=75)
Birthday
Paradox - Find
your twin 05
(unit?
unit=59&lesson=76)
What's your
favourite
movie? (unit?
unit=59&lesson=77)
Guess the
Movie Name
01 (unit?
unit=59&lesson=78)
Guess the
Movie Name
02 (unit?
unit=59&lesson=79)
Guess the
Movie Name
03 (unit?
unit=59&lesson=80)
Guess the
Movie Name
04 (unit?
unit=59&lesson=81)
Guess the
Movie Name
05 (unit?
unit=59&lesson=82)
Guess the
Movie Name
06 (unit?
unit=59&lesson=83)
Quiz :
Assignment 4
(assessment?
name=263)
Programming
Assignment-1:
Digits
(/noc20_cs35/progassignment?
name=280)
Programming
Assignment-
2: Factorial
(/noc20_cs35/progassignment?
name=281)
[Link] 3/4
02/07/2020 The Joy of Computing using Python - Course
Programming
Assignment-3:
Matrix
(/noc20_cs35/progassignment?
name=282)
Week 4
Feedback
(unit?
unit=59&lesson=283)
Week 5
Week 6
Week 7
Week 8
Week 9
Week 10
Week 11
Week 12
Text Transcripts
Download
Videos
Books
[Link] 4/4
02/07/2020 The Joy of Computing using Python - Course
([Link] ([Link]
reviewer4@[Link]
NPTEL ([Link] » The Joy of Computing using Python (course)
Announcements (announcements)
About the Course ([Link] Ask a Question (forum)
Progress (student/home) Mentor (student/mentor)
Programming Assignment-3: Matrix
Course Due on 2020-02-27, 23:59 IST
outline
You are provided with the number of rows (R) and columns (C). Your task is to
generate the matrix having R rows and C columns such that all the numbers are
How does an in increasing order starting from 1 in row wise manner.
NPTEL online
course work? Input Format:
The first line contain two numbers R and C separated by a space.
Week 0
Output Format:
Week 1 Print the elements of the matrix with each row in a new line and elements of
each row are separated by a space.
Week 2
NOTE: There should not be any space after the last element of each row and
Week 3 no new line after the last row.
week 4 Example:
Practice is the Input:
key (unit?
33
unit=59&lesson=60)
Magic Square: Output:
Hit and Trial 01 123
(unit? 456
unit=59&lesson=61)
789
Magic Square:
Hit and Trial 02 Explanation:
(unit? Starting from the first row, the numbers are present in the increasing order.
unit=59&lesson=62) Since it's a 3X3 matrix, the numbers are from 1 to 9.
Magic Square:
Sample Test Cases
Hit and Trial 03
Input Output
[Link] 1/4
02/07/2020 The Joy of Computing using Python - Course
(unit?
unit=59&lesson=63) 1 2 3 4
5 6 7 8
Magic Square: Test Case 1 4 4
9 10 11 12
Hit and Trial 04
13 14 15 16
(unit?
unit=59&lesson=64)
1 2 3 4 5
Magic Square: 6 7 8 9 10
Hit and Trial 05
Test Case 2 5 5 11 12 13 14 15
(unit?
16 17 18 19 20
unit=59&lesson=65)
21 22 23 24 25
Let's program
and play (unit?
1 2 3 4 5 6 7 8 9 10
unit=59&lesson=66)
11 12 13 14 15 16 17 18 19 20
Dobble Game - 21 22 23 24 25 26 27 28 29 30
Spot the 31 32 33 34 35 36 37 38 39 40
similarity 01 41 42 43 44 45 46 47 48 49 50
(unit? Test Case 3 10 10
51 52 53 54 55 56 57 58 59 60
unit=59&lesson=67)
61 62 63 64 65 66 67 68 69 70
Dobble Game - 71 72 73 74 75 76 77 78 79 80
Spot the 81 82 83 84 85 86 87 88 89 90
similarity 02 91 92 93 94 95 96 97 98 99 100
(unit?
unit=59&lesson=68)
1 2 3
Test Case 4 2 3
Dobble Game - 4 5 6
Spot the
similarity 03
1 2
(unit?
unit=59&lesson=69) Test Case 5 3 2 3 4
5 6
Dobble Game -
Spot the
1 2 3 4
similarity 04
(unit? Test Case 6 3 4 5 6 7 8
unit=59&lesson=70) 9 10 11 12
What is your
date of birth? The due date for submitting this assignment has passed.
(unit? As per our records you have not submitted this assignment.
unit=59&lesson=71) Sample solutions (Provided by instructor)
Birthday 1 a,b=map(int,input().split())
2
Paradox - Find 3 count=1
your twin 01 4 m = []
(unit? 5 for i in range(1,a+1):
6 l = []
unit=59&lesson=72) 7 for j in range(1,b+1):
8 [Link](count)
Birthday 9 count+=1
Paradox - Find 10 [Link](l)
your twin 02
11
12 for i in range(a):
(unit? 13 for j in range(b):
unit=59&lesson=73) 14 if(j==b-1):
15 print(m[i][j], end="")
Birthday 16 else:
17 print(m[i][j], end=" ")
Paradox - Find 18 if(i!=a-1):
your twin 03 19 print()
(unit?
unit=59&lesson=74)
[Link] 2/4
02/07/2020 The Joy of Computing using Python - Course
Birthday
Paradox - Find
your twin 04
(unit?
unit=59&lesson=75)
Birthday
Paradox - Find
your twin 05
(unit?
unit=59&lesson=76)
What's your
favourite
movie? (unit?
unit=59&lesson=77)
Guess the
Movie Name
01 (unit?
unit=59&lesson=78)
Guess the
Movie Name
02 (unit?
unit=59&lesson=79)
Guess the
Movie Name
03 (unit?
unit=59&lesson=80)
Guess the
Movie Name
04 (unit?
unit=59&lesson=81)
Guess the
Movie Name
05 (unit?
unit=59&lesson=82)
Guess the
Movie Name
06 (unit?
unit=59&lesson=83)
Quiz :
Assignment 4
(assessment?
name=263)
Programming
Assignment-1:
Digits
(/noc20_cs35/progassignment?
name=280)
Programming
Assignment-2:
Factorial
(/noc20_cs35/progassignment?
name=281)
[Link] 3/4
02/07/2020 The Joy of Computing using Python - Course
Programming
Assignment-
3: Matrix
(/noc20_cs35/progassignment?
name=282)
Week 4
Feedback
(unit?
unit=59&lesson=283)
Week 5
Week 6
Week 7
Week 8
Week 9
Week 10
Week 11
Week 12
Text Transcripts
Download
Videos
Books
[Link] 4/4