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...
1) Use Python to answer the below questions. a) What is the output of the following...
1) Use Python to answer the below questions. a) What is the output of the following python code?                         def function(x):                              return x * 5                        print(func(7) * func(5)) b) What is the output of the following code fragment?     required_course = "Programming", "Security", "Cybersecurity"         a,b,c = required_course         print(b)
Python language!!!!! №1 The translation from the Berland language into the Birland language is not an...
Python language!!!!! №1 The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if...
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...
Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this...
Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this try to use a level one skill python, like as if you just learned this don't use anything advanced if you can please. If not then do it as you can. Assume you have a file on your disk named floatnumbers.txt containing float numbers. Write a Python code that reads all the numbers in the file and display their average. Your code must handle...
language python use a functions and write a python of a computer with three power operations:...
language python use a functions and write a python of a computer with three power operations: power by two, power by three, and power by four. input a number and operation (^2,^3,or^4). output: the result of the power operation
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT