Hey Folks, In this article answers of Joy Of Computing Using Python Week 7 Assignment 2023. I am providing these answers to the best of my knowledge. Come with us until the last to know more about the assignment. I am also providing the coding section in this page only.Â
Joy Of Computing Using Python Week 7 Assignment 2023Â
Assignment 7Â
Q1. Values of CSV files are separated by ?
A. Commas
B. Colons
C. Semi-colons
D. Slash
Answer: [ A ]Â
Q2. What is the output of the following code?
 A. 1, 2, 3, 7, 11, 10, 9, 5, 6
 B. 1, 2, 3, 5, 6, 7, 9, 10, 11
 C. 1, 5, 9, 10, 11, 7, 3, 2, 6
 D. 1, 5, 9, 2, 6, 10, 3, 7, 11
Answer: [ C ]Â 1, 5, 9, 10, 11, 7, 3, 2, 6
Q3. What will be the output of the following code?
import turtleÂ
pen = turtle.Turtle()
for i in range(3):
   pen.forward(60)
   pen.right(120)
turtle.done() {codeBox}
A. Scalar triangle
B. Right angle triangle
C. Equilateral triangle
D. Isosceles triangle
Answer: [ C ]Â Â Equilateral triangle
Q4. Which of the following program will draw a hexagon?
 Answer: [ C ]Â
Q5. Which of the following library is used to render data on google maps?
A. gplot
B. googlemaps
C. gmplot
D. gmeplot
Answer: [ C ] gmplot
Q6. What is the output of the following code?
Q7. Which turtle command is equivalent to lifting up a pen.
 A. penlift()
 B. penup()
 C. uppen()
 D. penremove()
Answer: [ B ]Â penup()
Q8. Why do we use functions?
A. To improve readability.
B. To reuse code blocks.
C. For the ease of code debugging.
D. All of the above
Answer:Â [ D ]Â All of the above
Q9. Library used to import images?
 A. PIL
 B. Imageview
 C. IMG
 D. image
Answer: [ A ] PIL
Q10. In snakes and ladder what can be the ways to track ladders and snakes?
A. Maintain a dictionary with snakes or ladder number blocks as keys.
B. Using the if condition to check on every number.
C. Both A and B.
D. None of the above
Answer: [ C ] Both A and B
Programming Assignment
Q1. Given a sqaure matrix M, write a function DiagCalc which calculate the sum of left and right diagonals and print it respectively.(input will be handled by us)
Input:
A matrix MÂ
[[1,2,3],[3,4,5],[6,7,8]]Â
OutputÂ
13
13
Explanation:
Sum of left diagonal is 1+4+8 = 13
Sum of right diagonal is 3+4+6 = 13
Program Code:Â
def DiagCalc(L):
 L_sum=0
 R_sum=0
 m=L[::-1]
 for i in range(len(L)):
  for y in range(len(L)):
   if i==y:
    L_sum+=L[i][y]
    R_sum+=m[i][y]Â
 print(L_sum) Â
 print(R_sum,end="") {codeBox}
Q2. Given a matrix M write a function Transpose which accepts a matrix M and return the transposeÂ
of M. Transpose of a matrix is a matrix in which each row is changed to a column or vice versa.
InputÂ
A matrix M
[[1,2,3],[4,5,6],[7,8,9]]
Output
Transpose of M
[[1,4,7],[2,5,8],[3,6,9]]
import numpyÂfrom array import *def Transpose(M):Â Â arrays = numpy.array(M)Â Â num_list = arrays.transpose().tolist()Â Â return(num_list) {codeBox}
def snake(M): sk=0 sm=[] for r in M:  m=[]  sk=sk+1  if sk%2==0:   m=r[::-1]  else:   m=r  sm+=m return(sm) {codeBox}