NPTEL Joy Of Computing Using Python Week 7 Answers 2024

 Hey Folks, The wait is finally Over. This article is about NPTEL Joy of Computing Using Python Week 7 Answers. The answers are provided for free, No need to pay anything. Because we value our followers. Then why wait, let see the answers. 

Join Telegram:  CLICK HERE  for more updates and answers. 

NPTEL Joy Of Computing Using Python Week 7 Answers 2024

NPTEL Joy Of Computing Using Python week 7

Last Date to Submit: 13-03-24

Q1. The Chaupar game, also known as Pachisi, involves a player moving their pieces around a cross-shaped board based on the throw of dice (or cowrie shells). The objective is to reach the centre of the board. The steps required to implement the game are given below. 

The Chaupar game, also known as Pachisi, involves a player moving their pieces around a cross-shaped board based on the throw of dice (or cowrie shells). The objective is to reach the centre of the board. The steps required to implement the game are given below.

Arrange them in the correct order of implementation. The answer should be a sequence with the step numbers (Example:132)

1. Roll the dice (or simulate the throw of cowrie shells) to determine the number of steps the player can take. Move the player's piece based on the dice roll. Check if the new position is within the board limits. If it is, proceed; otherwise, stay at the current position.

2. Create a cross-shaped board with four arms, each having three columns of eight squares. Initialize the player's position to be inside the board at position 0..Define the centre of the board (position 24) as the goal.

3. Check if the player has reached or exceeded the centre of the board (position 24). If the player has reached the centre, declare them the winner. If not, proceed to the next player's turn and roll the die again and repeat the steps for each player

Answer: [ 213 ]

Q2. 

Given Below is a simple algorithm for a Snake and Ladder game
I)Create a board with positions numbered from 1 to 100. Define the positions of snakes and ladders on the board. Each snake or ladder connects two positions.

II) Roll the dice to get a random number between 1 and 6. Move the player's piece forward by the number obtained from the dice roll.

Check if the new position contains the head of a snake or the bottom of a ladder. If it does, move the player to the corresponding position as per the snake or ladder.

III)Check if the player has reached or exceeded position 100. If the player has reached or exceeded 100 declare them the winner. If not, proceed to the next player's turn. Repeat the process for each player's turn until a player wins.

The following variations were suggested for the algorithm.

A. If we are using an octahedral dice instead of a normal die, Step II) has to be changed to generate a random number between 1 and 8

B. Modification is required only in step I) if we use a board consisting of 200 tiles instead of 100


C. Modification is required in both steps I) and III) if we use a board consisting of 200 tiles instead of 100

Identify the correct Statements 

a. A and B 

b. Only B 

c. A and C 

d. Only C 

Answer: A and B 

Q3. Nishan enjoys the game of snake and ladders but feels that the player should be given an extra chance if the player lands on a prime-numbered tile (Assume that no prime-numbered tile has a snake or ladder in it).

He generates the following function is_prime(position) to check if the position of the player is prime or not. However, there is a chance that there could be a small error in the code. Identify the line number corresponding to the error, in the absence of an error answer -1. 

def is_prime(position):  
      if position<=2: 
          return False
      for i in range ( 2, int (position**0.5)+1): 
            if position%i == 0 : 
                return False
      return True{codeBox}

Answer: 2

Q4. Find the error in the line of code written using the library turtle to draw a square. In the absence of an error enter the answer as -1. 

import turtle 
screen = turtle.Screen( )
squ = turtle.Turtle( ) 

for i in range ( 3 ): 
      squ.forward ( 100 )
      squ.right ( 90 ) {codeBox}

Answer: 7

Q5. Like the spiral pattern, the matrix can be printed in many patterns and forms. In the snake pattern, the elements of the row are first printed from left to right and then the elements of the next row are printed from right to left and so on.


Like the spiral pattern, the matrix can be printed in many patterns and forms. In the snake pattern, the elements of the row are first printed from left to right and then the elements of the next row are printed from right to left and so on.

A crucial step in the algorithm to print the snake pattern is to check the row parity (remainder when the row number is divided by 2). Identify the correct statements regarding this step. (Assume the normal row indexing in a matrix starting from 0) [MSQ]

A. When parity is 0, we print the elements of the row from left to right
B. When parity is 1, we print the elements of the row from left to right
C. When parity is 0, we print the elements of the row from right to left
D. When parity is 1, we print the elements of the row from right to left

Answer: [ A ]  and [ D ] 

Q6. Which of these conditions guarantee that the element is a boundary element of the matrix of order m by n? Take i as the row index and j as the column index of the element of to be checked [MSQ]

A. i==0
B. i== m-1
C. j==0
D. j==n-1

Answer: [ A ] [ B ] [ C ] [ D ] 

Q7. Given a set of 4 integers as input, the following code tries to print the elements in the form of a square matrix of order 2 . But the code might contain errors. Identify the line number corresponding to the error, In the absence of an error give your answer as -1.


Answer: -1

Q8. How can you write data to a CSV file using the `csv` module?
A. `write_csv_file()`
B. `csv.writer()`
C. `csv.write()`
D. `write_csv()`

Answer: [ B ] `csv.writer()`

Q9. Which object is commonly used for reading rows from a CSV file in Python?
A. 'csv.parser`
B. `csv.handler`
C. `csv.reader`
D. `csv.iterator`

Answer: [ C ] `csv.reader`

Q10. Identify the correct statement(s) regarding the gmplot library

I) gmplot is a Python library that allows you to plot data on Google Maps.
II) The syntax for creating a base map with gmplot is
gmplot.GoogleMapPlotter(latitude, longitude, zoom)
the parameters are the geographical coordinates i.e., Latitude and Longitude and the zoom resolution

A. I only
B. II only
C. Both I and II
D. Neither I nor II

Answer: [ C ] Both I and II 

Conclusion 

Follow us on Telegram for any Updates. 

Join Telegram:  CLICK HERE  for more updates and answers. 


One Comment Please !

Post a Comment (0)
Previous Post Next Post