In: Computer Science
NOTE give complete and accurate answers FOR 30 marks
1(a) A Give the output for the(2*5)
array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729])
a. a[:6:2] = -1000 (ii) a[ : :-1] )
b. Display the values of 1D array using for loop?
c. Write a code to print a 3D array?
d. How to print the transpose of a 2D array?
e Write a function to sort the array row and coloumn wise ?
(b) You are the class representative and your class advisor always requests your help to prepare the result analysis after each internal assessment. One of the tasks that your class advisor has assigned to you is to find whether a student has scored a 0 in a course.Given the scores of the 'n' students in the class, write a python program to find whether how many students have scored a zero in a course. Use arrays to store the marks of the students and assume that the maximum number of students in a class is 50.(5)
(c) Normally in all engineering colleges, there will be a long vacation after every even semester and a short vacation after every odd semester.Create a program in python to determine whether he will have a long vacation or short vacation at the end of a particular semester.(5)
(d) Design a 2D array to store the marks of six subjects of a student and display its total marks and average percentage?(5)
(e) Differentiate between VIEW and COPY?(5)
A Give the output for the(2*5)
array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729])
a. a[:6:2] = -1000 (ii) a[ : :-1] )
b. Display the values of 1D array using for loop?
c. Write a code to print a 3D array?
d. How to print the transpose of a 2D array?
e Write a function to sort the array row and coloumn wise ?
Q2. You are the class representative and your class advisor always requests your help to prepare the result analysis after each internal assessment. One of the tasks that your class advisor has assigned to you is to find whether a student has scored a 0 in a course.Given the scores of the 'n' students in the class, write a python program to find whether how many students have scored a zero in a course. Use arrays to store the marks of the students and assume that the maximum number of students in a class is 50.(5)
Q3 Normally in all engineering colleges, there will be a long vacation after every even semester and a short vacation after every odd semester.Create a program in python to determine whether he will have a long vacation or short vacation at the end of a particular semester.(5)
Q4 Design a 2D array to store the marks of six subjects of a student and display its total marks and average percentage?(5)
Q5 Differentiate between VIEW and COPY?(5)
A Give the output for the(2*5)
array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729])
a. a[:6:2] = -1000 (ii) a[ : :-1] )
b. Display the values of 1D array using for loop?
c. Write a code to print a 3D array?
d. How to print the transpose of a 2D array?
e Write a function to sort the array row and coloumn wise ?
Q2. You are the class representative and your class advisor always requests your help to prepare the result analysis after each internal assessment. One of the tasks that your class advisor has assigned to you is to find whether a student has scored a 0 in a course.Given the scores of the 'n' students in the class, write a python program to find whether how many students have scored a zero in a course. Use arrays to store the marks of the students and assume that the maximum number of students in a class is 50.(5)
Q3 Normally in all engineering colleges, there will be a long vacation after every even semester and a short vacation after every odd semester.Create a program in python to determine whether he will have a long vacation or short vacation at the end of a particular semester.(5)
Q4 Design a 2D array to store the marks of six subjects of a student and display its total marks and average percentage?(5)
Q5 Differentiate between VIEW and COPY?(5)
A Give the output for the(2*5)
array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729])
a. a[:6:2] = -1000 (ii) a[ : :-1] )
b. Display the values of 1D array using for loop?
c. Write a code to print a 3D array?
d. How to print the transpose of a 2D array?
e Write a function to sort the array row and coloumn wise ?
Q2. You are the class representative and your class advisor always requests your help to prepare the result analysis after each internal assessment. One of the tasks that your class advisor has assigned to you is to find whether a student has scored a 0 in a course.Given the scores of the 'n' students in the class, write a python program to find whether how many students have scored a zero in a course. Use arrays to store the marks of the students and assume that the maximum number of students in a class is 50.(5)
Q3 Normally in all engineering colleges, there will be a long vacation after every even semester and a short vacation after every odd semester.Create a program in python to determine whether he will have a long vacation or short vacation at the end of a particular semester.(5)
Q4 Design a 2D array to store the marks of six subjects of a student and display its total marks and average percentage?(5)
Q5 Differentiate between VIEW and COPY?(5)
A Give the output for the(2*5)
array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729])
a. a[:6:2] = -1000 (ii) a[ : :-1] )
b. Display the values of 1D array using for loop?
c. Write a code to print a 3D array?
d. How to print the transpose of a 2D array?
e Write a function to sort the array row and coloumn wise ?
Q2. You are the class representative and your class advisor always requests your help to prepare the result analysis after each internal assessment. One of the tasks that your class advisor has assigned to you is to find whether a student has scored a 0 in a course.Given the scores of the 'n' students in the class, write a python program to find whether how many students have scored a zero in a course. Use arrays to store the marks of the students and assume that the maximum number of students in a class is 50.(5)
Q3 Normally in all engineering colleges, there will be a long vacation after every even semester and a short vacation after every odd semester.Create a program in python to determine whether he will have a long vacation or short vacation at the end of a particular semester.(5)
Q4 Design a 2D array to store the marks of six subjects of a student and display its total marks and average percentage?(5)
Q5 Differentiate between VIEW and COPY?(5)
Q.) (a)
a. (i) [0, 8, 64]
(ii) [729, 512, 343, 216, 125, 64, 27, 8, 1, 0]
b. #Let a be the 1D array:
for i in a:
print(i)
c. import numpy as np #imports the numpy package of Python
b = np.zeros((3,3,3)) #creates a 3D array
print(b)
d. #Let a be the array.
import numpy as np
c = a.reshape(2,5) #Reshapes a and stores in c.
print(np.transpose(c)) #prints transpose of c
e. #Let the array be l.
import numpy as np
l = l[np.argsort(l[:,0])] #sorts the array by rows.
print(l)
l = l[:, l[0].argsort()] #sorts the array by columns.
print(l)
(b). #Let l be the list of students in the class.
counter = 0
for i in l: #iterates over the elements of the list.
if i==0:
counter += 1
print(counter)
(c). n = int(input("Enter your semester number: ")) #taking input for the semester number
if (n%2)!=0: #checking whether the semester is odd
print("Short vacation.")
else:
print("Long vacation.")
(d). import numpy as np #imports the numpy package
sum = 0
percentage = 0
l = np.array([[1,2,3,4,5,6],[10,20,30,40,50,60]]) #creating a 2D array in python
for i in range(6): #iterating over the array
sum += l[1][i] #taking sum of the marks
percentage += (l[1][i] / 100)*100
average_percentage = (percentage) / 6
print("Total sum is: ", sum)
print("Average percentage is: ", average_percentage)
(e). The basic difference between a view and copy of an array is that the copy creates a new array i.e. as a copy of the original array whereas view just depicts the view of the original array. Hence, the changes made within the copy of the array does not affect the original one, but changes made in the view array affect the original array.