[Type B] Chapter– 8 Class 12 CS – Sumita Arora Assignment | Q/A

Here is class 12 computer science Unit 8 [Type B] solutions for Sumita Arora back exercise assignment. Below includes both textual and video solutions wherever required. View all the answers in assignment for chapter 8 and for all chapters here.

Watch all tutorials for chapter 8.

Q1: Consider the code below:
Chapter 8 Type-B Sumita Arora
Question 1

Solution:

Solution
(a)
Q2: Execute the following codes and find out what happens? (Libraries have been imported already : plt is the alias name for matplotlib.pyplot)
Chapter 8 Type-B Sumita Arora
Question 2

Solution:

(a) No error
(b) No error
(c) The code will execute with no error but it will have an improper visualization due to the wrong value as parameter passed on.
Q3: Add titles for the X-axis, Y-axis and for the whole chart in above codes.
(a)
A = np.arange(2, 20, 2)
B = np.log(A)
plt.plot(A, B)
plt.title('log')
plt.xlabel("X axis")
plt.ylabel("Y axis")
plt.show()

(b)
A = np.arange(2, 20, 2)
B = np.log(A)
plt.bar(A, B)
plt.title('log')
plt.xlabel("X axis")
plt.ylabel("Y axis")
plt.show()
Q4: plt.plot(A,B) produces (A and B are the sequences same as created in question 2) chart as:
Chapter 8 Type-B Sumita Arora
Question 4

Solution:

import matplotlib.pyplot as plt
import numpy as np

# code for A vs B's every value*1.2

A = np.arange(2, 20, 2)
B = np.log(A)
B1 = B*1.2
plt.plot(A, B)
plt.plot(A, B1)
plt.show()

# code for A vs B's every value*-1.2

A = np.arange(2, 20, 2)
B = np.log(A)
B1 = B*-1.2
plt.plot(A, B)
plt.plot(A, B1)
plt.show()
Q5: Why is following command producing error? (plt is the alias name of imported library matplotlib.pyplot and A is an ndarray created in question 2)

plt.pie(A, A+2, A+3, A+4)
Improper argument passed is the cause of error while plt.pie() requires different argument.

ValueError: Invalid RGBA argument: 6

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

You cannot copy content of this page