Question

In: Computer Science

NOTE give complete and accurate answers FOR 30 marks 1(a) A Give the output for the(2*5)...

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)


This is a python assignment

Solutions

Expert Solution

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.


Related Solutions

Output and Debugging Questions (10 marks each) [20 Marks] Note: Provide a copy of the code...
Output and Debugging Questions (10 marks each) [20 Marks] Note: Provide a copy of the code and screen shot for the output in the solutions’ 1. Trace the following program and write the exact output for the following inputs. Explain each output. [10 Marks] a. Input of an array { 20, 80 , 63, 89 } b. Input of an array { 1, 2 ,3, 4} c. Input of an array { 100, 200 ,300, 400} d. Input of an...
This is assessment 2: Research Essay 30 marks Length 3,000 words Please note that this question...
This is assessment 2: Research Essay 30 marks Length 3,000 words Please note that this question requires substantial research (see the assessment criteria below). (a) Explain how GDP is measured in your country. Provide real life examples. While your textbook is your first point of reference, you should consult other references in order to receive full marks. Use real life examples (with references) to support your discussion.    (b) Explain the macroeconomic effects of COVID-19 pandemic on your country using...
''' Problem 2: Functions that give answers Define and complete the functions described below. The functions...
''' Problem 2: Functions that give answers Define and complete the functions described below. The functions are called in the code at the very bottom. So you should be able simply to run the script to test that your functions work as expected. ''' ''' * function name: get_name * parameters: none * returns: string * operation: Here, I just want you to return YOUR name. The expected output below assumes that your name is Paul. Of course, replace this...
Question 5 (10 marks) Python Language What is the output of the following code ? (2...
Question 5 Python Language What is the output of the following code ? (2 points) a, b = 0, 1 while b < 10: print b a, b = b, a+b B. Explain List Comprehension (2 points) Given v = [1 3 5] w = [ [2*x, x**2] for x in v] What is the content of w? c. What is tuple ?   What is the difference between tuple and list ? (2 points) D. What is a module ?  ...
(Please provide references with answers) Part 2 (Motivation – 30 marks) Discuss how you will motivate...
(Please provide references with answers) Part 2 (Motivation – 30 marks) Discuss how you will motivate your employee by using one of the following motivational theories 1. Maslow’s Theory 2. Theory X and Theory Y Your choice should be justified with the support of related literature (300 words) (Please provide references with answers)
Complete this question by entering your answers in the tabs below. Required 1 Required 2 Complete...
Complete this question by entering your answers in the tabs below. Required 1 Required 2 Complete the above schedule of the company’s total costs and costs per unit. (Round the per unit variable cost and fixed cost to 2 decimal places.) Units Produced and Sold 69,000 89,000 109,000 Total costs: Variable costs $213,900 Fixed costs 390,000 Total costs $603,900 $0 $0 Cost per unit: Variable cost Fixed cost Total cost per unit $0.00 $0.00 $0.00
Question 2 (30 marks) (a) Identify any THREE (3) input devices and THREE (3) output devices...
Question 2 (a) Identify any THREE (3) input devices and THREE (3) output devices which are common used in our life. Discuss the benefits of using these devices in our daily life. [18 marks] Each point 3 marks.
Complete the two Available-to-Promise tables below. a. On-hand = 30 Period 1 2 3 4 5...
Complete the two Available-to-Promise tables below. a. On-hand = 30 Period 1 2 3 4 5 6 Forecast 100 50 100 50 100 50 Customer Orders 75 50 116 73 45 23 Master Production Schedule 100 200 150 Available-to Promise b. On-hand = 100 Period 1 2 3 4 5 6 Forecast 50 100 50 100 100 150 Customer Orders 75 125 75 135 45 53 Master Production Schedule 200 200 200 Available-to Promise
Give a brief account of a. [5 marks] Rayleigh scattering, b.[5 marks] the photoelectric effect, c....
Give a brief account of a. [5 marks] Rayleigh scattering, b.[5 marks] the photoelectric effect, c. [5 marks] the Compton effect and d. [5 marks] pair/triplet production. For each of them, describe the phenomenon, account for it in terms of physical principles, and state the photon energy range and atomic number Z of target material over which it is important.
SECTION A (30 marks) This section consists of ONE (1) compulsory question QUESTION 1 (30 marks)...
SECTION A This section consists of ONE (1) compulsory question QUESTION 1 ABC Ltd is a wholesaler of furniture which has been in operation for ten years. It buys furniture from five major manufacturers and sells them to a range of customers. The company currently has a customer base of over 500 customers most of which are credit customers. The receivables balance comprises customers owing up to $2,000,000 to smaller balances of about $10,000, all with many different due dates...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT