Question

In: Computer Science

Add the result envidented by the python compiler. use python language. 1(a) A Give the output...

Add the result envidented by the python compiler.
use python language.


1(a) A Give the output for the

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.



(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.



(d) Design a 2D array to store the marks of six subjects of a student and display its total marks and average percentage?



(e) 5 DifferenCE between VIEW and COPY?

Solutions

Expert Solution

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 )

n = int(input("Enter your semester number: "))

if (n%2)!=0: #checking whether the semester is odd

print("Short vacation.")

else:

print("Long vacation.")

========================================================================================

d )

import numpy as np
sum = 0
percentage = 0
l = np.array([[1,2,3,4,5,6,7],[10,20,30,40,50,60,70]])
for i in range(6):
sum += l[1][i]
percentage += (l[1][i] / 100)*100
average_percentage = (percentage) / 6
print("Total sum is: ", sum)
print("Average percentage is: ", average_percentage)

========================================================================================

ANSWERED AS PER KNOWLEDGE

IF ANY DOUBT COMMENT IT


Related Solutions

Interpreter and compiler are two methods to convert high level languages to machine language. How Python...
Interpreter and compiler are two methods to convert high level languages to machine language. How Python and C++ language works?
-------------------------Don't give Incomplete Answer-------------- A compiler translates the code written in one language to some other...
-------------------------Don't give Incomplete Answer-------------- A compiler translates the code written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target code efficient and optimized in terms of time and space. Compiler design principles provide an in-depth view of translation and optimization process. Compiler design covers basic translation mechanism and error detection & recovery. It includes lexical, syntax, and semantic analysis as front end, and code...
-------------------------Don't give Incomplete Answer-------------- A compiler translates the code written in one language to some other...
-------------------------Don't give Incomplete Answer-------------- A compiler translates the code written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target code efficient and optimized in terms of time and space. Compiler design principles provide an in-depth view of translation and optimization process. Compiler design covers basic translation mechanism and error detection & recovery. It includes lexical, syntax, and semantic analysis as front end, and code...
In Python, write a calculator that will give the user the following menu options: 1) Add...
In Python, write a calculator that will give the user the following menu options: 1) Add 2) Subtract 3) Multiply 4) Divide 5) Exit Your program should continue asking until the user chooses 5. If user chooses to exit give a goodbye message. After the user selections options 1 - 4, prompt the user for two numbers. Perform the requested mathematical operation on those two numbers. Round the result to 1 decimal place. Example 1: Let's calculate! 1) Add 2)...
Problem 2 [6pt] In early implementations of Fortran language, a compiler may choose to use static...
Problem 2 [6pt] In early implementations of Fortran language, a compiler may choose to use static allocation (i.e., allocation in the static area) for local variables and parameters, effectively arranging for the variables of different invocations to share the same locations, and thereby avoiding any run-time overhead for creation and destruction of stack frames. However, such implementation changes the meaning of recursive function calls. Write down a simple example and explain how its meaning changes under the “Fortran” semantics as...
Writing a Modular Program in Python In this lab, you add the input and output statements...
Writing a Modular Program in Python In this lab, you add the input and output statements to a partially completed Python program. When completed, the user should be able to enter a year, a month, and a day. The program then determines if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared...
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 ?  ...
Use the Compiler Explorer with the MIPS compiler to compile the following C code. Assuming this...
Use the Compiler Explorer with the MIPS compiler to compile the following C code. Assuming this function is called with the parameter n = 5… int summarize(int n) { int sum = 0; for (int i = 0; i < n; i++) { sum += i; } return sum; } c) Compile the code using the ARM gcc 8.2 compiler. Add the –O1 compiler option, which asks the compiler to optimize for speed (at least to one level). What is...
Use the Compiler Explorer with the MIPS compiler to compile the following C code. Assuming this...
Use the Compiler Explorer with the MIPS compiler to compile the following C code. Assuming this function is called with the parameter n = 5… int summarize(int n) { int sum = 0; for (int i = 0; i < n; i++) { sum += i; } return sum; } a) Accounting for delay slots, what is the dynamic instruction count of this routine? What is the dynamic instruction count if you add the –O1 compiler option, which asks the...
Python Add your own implementation of the function rearrange_list rearrange_list(linkedlist, number) returns the result of rearranging...
Python Add your own implementation of the function rearrange_list rearrange_list(linkedlist, number) returns the result of rearranging the nodes in linkedlist so that: all the nodes whose values are less than number are at the front all the nodes whose values are greater than number are at the rear any nodes whose values are equal to number are in the middle For example, given the linked list represented by linkedlist = -2 -> -3 -> -1 -> 2 -> 3 ->...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT