1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
egoroff_w [7]
3 years ago
10

Answer the following Python Interview questions • How is Python an interpreted language? • What is the difference between Python

Arrays, lists, tuples, and records? Explain it with examples • What does [::-1] do? Explain it with an example • How can you randomize the items of a list in place in Python? • What is the difference between range & xrange?Explain it with an example • What advantages do NumPy arrays offer over (nested) Python lists? • How to add values to a python array? Explain it with an example • What is split used for? Explain it with an example

Computers and Technology
1 answer:
8_murik_8 [283]3 years ago
7 0

Answer:

1. Python is called as interpreted language. However as a programming language it is not fully compiled nor interpreted language. Python program runs from direct source code which makes it byte code interpreted.

An Interpreter is the one which takes the code and performs the actions specified in the code. It turns the code into intermediate language which is again translated to machine language understood by the processor. Interpreted or compiled are the property of the implementation and not of the language.

2. Array : It is a collection of same data type elements stored at contagious memory location. It is handled in python with module array. All the elements of array must be of same data type. In order to manipulate same data types arrays are used.

Ex: array1 = a.array ('i', [10, 20, 30]) this is a array of integer type.

Lists : Python lists are ordered data structure and are like non homogeneous dynamic sized arrays. It may contain integers, strings, boolean, or objects.

Ex: List1 = [70, 89, 98] , List2 = ["Rose", "Lilly", "Jasmine"]

List3 = [1, 10, 100, 'Test', 'Test1']

Tuple : It is a collection of objects separated by commas and they are immutable. It is static which makes them faster.

Ex: tupule1 = ('element1', 'element2')

List and Tuple in Python are the class of data structure. The list is dynamic, whereas tuple has static characteristics.

Lists are mutable but tuples are not.

tuples are mainly used to access the elements where as lists are used in operations like insertion and deletion.

Iterations are time consuming in list where as it is faster in tuples.

tuples don't have inbuilt methods but list has many builtin methods.

tuples takes slightly less memory that lists in Python

Records: Records data structure will have fixed number of fields and each field may have a name and different type. Immutable records are implemented using named tuple.

3. Syntax of slice in python is list[<start>:<stop>:<step>] and it can be used on tuples and lists.

so X [::-1] means that it will start from the end towards the first element by taking each of the elements.

for ex: X = '9876'

X [::-1] will result in '6789'.

Means it will reverse all the elements in the array.

4. Items of list can be shuffled with the random.shuffle() function of a random module.

Syntax is : random.shuffle(x, random)

x- It is a sequence to shuffle and can be list or tuple.

random- it is a optional argument which returns random float number between 0.1 to 1.0.

5. range() – Range function returns a range object which is a type of iterable object.

xrange() – xrange function returns the generator object that can be used to display numbers only by looping. Only particular range is displayed on demand and hence called “lazy evaluation“.

• Return type of range () is range object whereas that of xrange() is xrange object.

• Variable to store the range using range () takes more memory but xrange takes comparative less memory.

• Range returns the list but xrange returns the xrange object. Hence operations on list can be applied for range but not on xrange.

• Xrange is faster to implement than range as xrange evaluates only generator objects.

• Xrange is depreciated in Python 3 and above.

For ex :

x = range (10, 100)

y= xrange (10, 100)

#To know the return type we can print it

print ( return type of range () is : “)

print (type (x))

print ( return type of xrange () is : “)

print (type (y))

Output will be list and xrange respectively.

6. NumPy's arrays are more compact than Python lists

reading and writing items is also faster with NumPy.

Memory taken by python lists are way higher than NumPy arrays.

Python lists don’t support vectorized operation.

Since lists can contain objects of different types its type information must be stored and executed every time operation is performed on it.

Memory taken by python lists are a lot higher than that of NumPy Arrays.

Reading and writing of elements in NumPy arrays are faster than lists.

NumPy arrays are compact and accumulate lesser storage.

Numpy is convenient and efficient.

For ex :

Metrics operations are easy in NumPy.

Checkerboard pattern can be done using NumPy.

7. Attached as Image

8. split() method returns a list of strings after breaking the given string by the specified separator. It is splitting of string into list with each word is a list item.

Syntax : str.split ( separator, maxsplit)

Separator : its is delimiter used and by default whitespace is used as separator.

Maxsplit : Maximum number of times to split the string. By default it has no limit.

For ex:

text = 'apples and oranges are different '

print(text.split())

output will be : ['apples', 'and', 'oranges', 'are', 'different' ]

Explanation:

You might be interested in
Select the correct answer.
pav-90 [236]

Answer:

your answer would be D.0

Explanation:

3 0
3 years ago
c++ Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value is c
Ksivusya [100]

<u>Answer:</u>

<em>int fNumber,scndNumber = -1,  </em>

<em>dup = 0; </em>

<em>do { </em>

<em>cin >> fNumber; </em>

<em>if ( scndNumber == -1) { </em>

<em>scndNumber = fNumber; </em>

<em>} </em>

<em>else { </em>

<em>if ( scndNumber == fNumber ) </em>

<em>duplicates++; </em>

<em>else </em>

<em>scndNumber = fNumber; </em>

<em>} </em>

<em>} while(fNumber > 0 );  </em>

<em>cout << dup; </em>

<u>Explanation:</u>

Here three variables are declared to hold the first number which is used obtain all the inputs given by the user, second number to hold the value of <em>last encountered number and “dup” variable to count the number of duplicate values.</em>

<em>“Do-while”</em> loop help us to get the input check whether it is same as previous input if yes then it <em>adds to the duplicate</em> value otherwise the new previous value if stored.

4 0
2 years ago
Read 2 more answers
Select all the items of the Design Elements.
maks197457 [2]
Answer: A: B: E: I think
5 0
2 years ago
What is the boundary folding method?
Romashka [77]

Answer:

 Boundary folding method is basically used in the java algorithm and in the hash table. In the hash function, the left and the right value are basically folded in the fixed boundary between the given center values by using the boundary folding methods.

There are basically two types of folding method in the hashing that are:

  • Folding shift
  • Folding boundary

In the folding boundary method the outside value are get reversed and the alternate values are get flipped at the boundary folding method.

4 0
3 years ago
Servers that exist within a data center that is publicly accessible on the internet are referred to as on-premises servers.
adoni [48]

Servers that exist within a data center that is publicly accessible on the internet are referred to as on-premises servers: b. false.

<h3>What is a server?</h3>

A server can be defined as a dedicated computer system that is designed and developed to provide specific services to other computer devices or programs, which are commonly referred to as the clients.

<h3>What is an on-premises server?</h3>

An on-premises server can be defined as a type of server that are privately owned by a company or individuals, which must be managed and maintained individually.

In conclusion, servers that exist within a data center that is not publicly accessible on the internet are generally referred to as on-premises servers.

Read more on servers here: brainly.com/question/27960093

#SPJ1

7 0
1 year ago
Other questions:
  • Because public key encryption requires the use of two different keys, it is also known as _____ encryption
    13·1 answer
  • What is encyclopedia. Com considered to be?
    14·1 answer
  • A company gives you a document to review. This document lays out the strengths and weaknesses of a proposed business venture. It
    13·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    7·1 answer
  • "background" software that helps the computer manage its own internal resources is called ________.
    5·1 answer
  • economists measure the personal satisfaction someone gets from consuming goods and services with the concept of.....?
    6·1 answer
  • What does digital mean, in the term of computer science.
    11·1 answer
  • A person who creates a computer virus is a (1)system analyst (2) techician(3) programmer​
    11·2 answers
  • Which of the following is true of lossy and lossless compression techniques?
    13·1 answer
  • A system engineer enhances the security of a network by adding firewalls to both the external network and the internal company n
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!