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
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.Â
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
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}
import turtleÂscreen = turtle.Screen( )squ = turtle.Turtle( )Âfor i in range ( 3 ):ÂÂ Â Â squ.forward ( 100 )Â Â Â squ.right ( 90 ) {codeBox}
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
B. i== m-1
C. j==0
D. j==n-1
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
B. II only
C. Both I and II
D. Neither I nor II