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
What are the Strategies to Maintain a Healthy Sales Funnel?
il63 [147K]

Answer:

  • Use LinkedIn Automation Tools to Level Up Your Prospecting Game
  • Know Your Target Audience
  • Sync With Prospects' Interests
  • Polish Your LinkedIn Profile

Creating and maintaining a healthy sales pipeline is challenging but not impossible.  

The B2B world has changed, and you need to adopt new strategies to build a healthy pipeline. Choose the best LinkedIn automation tool, optimize your profile, know your audience and share personalized content for quick outcomes.

7 0
3 years ago
May someone do this please? Thanks!!
vovangra [49]

Answer:Jeez

Explanation: thats a lot

5 0
3 years ago
Secondary storage devices that are input and output devices include all except:
inessss [21]
Output devices. You're welcome
6 0
4 years ago
You have enabled IP routing on PLABSA01 after enabling the IPRouter in the registry. How will you verify whether the IP routing
drek231 [11]

Answer:

By typing ipconfig at the command prompt

Explanation:

To check if an ip router is enabled in a registry, simply do the following:

1. launch your command prompt from accessories in your windows start button

2. Type this command IPconfig

3. Strike the enter button on the keyboard

It will display the various pack of upload and download indicating how packages are routed.

4 0
3 years ago
Fill in the missing terms relating to computer software
Tcecarenko [31]

The missing terms relating to computer software are:

  • Utilities
  • application software.
<h3>What are Programs designed to perform specific tasks?</h3>

Programs that are made to carry out specific tasks is known as application software.

Note that An application software is said to be a computer software set up to carry out a group of coordinated functions and as such, The missing terms relating to computer software are:

  • Utilities
  • application software.

Learn more about computer software from

brainly.com/question/1538272

#SPJ1

6 0
2 years ago
Other questions:
  • Where is authorization management app on tablet?
    7·1 answer
  • What is looping in QBASIC​
    9·1 answer
  • A(n) ______ is software that finds websites, webpages, images, videos, and other information related to a specific topic.
    11·1 answer
  • Why is democracy the best form of government
    5·1 answer
  • We have three containers whose sizes are 10 pints, 7 pints, and 4 pints, respectively. The 7-pint and 4-pint containers start ou
    14·2 answers
  • The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t
    15·1 answer
  • Obtaining the data of a video file from a flash drive is an example of a(n) _________ operation.
    6·1 answer
  • If you want to protect your identity while social networking, then you might use a(n) ____________ for your profile image
    7·1 answer
  • PLEASE HELP AND FAST!!!!!<br>Which of the following devices uses binary code?
    6·2 answers
  • Next
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!