Blog

Python Interview Questions

What is Python?

Python was created by Guido van Rossum, and released in 1991. It is a general-purpose computer programming language. It is a high-level, object-oriented language which can run equally on different platforms such as Windows, Linux, UNIX, and Macintosh. It is widely used in data science, machine learning and artificial intelligence domain.

What are the applications of Python?

Python is used in various software domains some application areas are given below.

  • Web and Internet Development
  • Games
  • Scientific and computational applications
  • Language development
  • Image processing and graphic design applications
  • Enterprise and business applications development
  • Operating systems
  • GUI based desktop applications

What are the advantages of Python?

  • Interpreted: Python is an interpreted language. It does not require prior compilation of code and executes instructions directly.
  • Free and open source: It is an open source project which is publicly available to reuse. It can be downloaded free of cost.
  • Portable: Python programs can run on cross platforms without affecting its performance.
  • Extensible: It is very flexible and extensible with any module.
  • Object-oriented: Python allows to implement the Object Oriented concepts to build application solution.
  • Built-in data structure: Tuple, List, and Dictionary are useful integrated data structures provided by the language.

What are the built-in type does python provides?

There are mutable and Immutable types of Pythons built in types Mutable built-in types

  • List
  • Sets
  • Dictionaries

Immutable built-in types

  • Strings
  • Tuples
  • Numbers

What is the difference between list and tuple?

The difference between list and tuple is that list is mutable while tuple is not. Tuple can be hashed for example as a key for dictionaries.

 In Python what is slicing?

A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing.

What is negative index in Python?

Python sequences can be index in positive and negative numbers. For positive index, 0 is the first index, 1 is the second index and so forth. For negative index, (-1) is the last index and (-2) is the second last index and so forth.

How you can convert a number to a string?

In order to convert a number into a string, use the inbuilt function str(). If you want a octal or hexadecimal representation, use the inbuilt function oct() or hex().

What is the use of // operator in Python?

It is a Floor Division operator , which is used for dividing two operands with the result as quotient showing only digits before the decimal point. For instance, 10//5 = 2 and 10.0//5.0 = 2.0.

What is the use of the split function in Python?

The use of the split function in Python is that it breaks a string into shorter strings using the defined separator. It gives a list of all words present in the string.

How do you get a list of all the keys in a dictionary?

For this, we use the function keys().

>>> mydict={‘a’:1,’b’:2,’c’:3,’e’:5}

>>> mydict.keys()

output: dict_keys([‘a’, ‘b’, ‘c’, ‘e’])

Define Pass statement in Python?

A Pass statement in Python is used when we cannot decide what to do in our code, but we must type something for making syntactically correct.

Join our Python course. Check out the syllabus for Python.

Leave a Reply

Your email address will not be published. Required fields are marked *