• [email protected]
  • +91 8431610064
Introtallent
  • Hire From Us
  • Student
    • Resources
      • SQL Interview Questions
      • Tableau Interview Questions
      • Power BI Interview Questions
      • Excel Interview Questions
      • Python Interview Question
    • LMS Login
  • Login
  • |
  • Sign up
    • Login
    • Sign up

Python Interview Questions

  • Introtallent Team
  • April 1, 2021June 23, 2022
  • Courses, Programming

1) What is Python?

Ans: Python is a high-level, interpreted, general-purpose programming language. It is an object oriented programming language and is used across industry for several purpose like Application Development, Data Science, Analytics, Machine Learning, Web Development, Games Development, etc.

2) What are the different data types Python?

Data types in python are:

– Numbers

– Strings

– Lists

– Tuples

– Dictionary

3) What is the difference between Python arrays and lists?

Arrays can only contain elements of same data types i.e., data type of array should be homogeneous.

Lists can contain elements of different data types i.e., data types of lists can be heterogeneous. 

4) Explain mutable and immutable objects?

Mutable objects: Objects that allow modifying their contents are called mutable objects. Like lists, sets, and dictionary are the example of mutable objects.

Immutable objects: Objects that don’t allow modifying their contents are called immutable objects. Like booleans, integers, floats,  strings, and tuples are the example of immutable objects.

5) What is lambda in Python?

Lambda is an anonymous function in Python. It can accept any number of arguments, but can only have a single expression. We use lambda function in a situation when we need an anonymous function for a short time period.

example: 

my_sum=lambda x,y:x+y

6) What is the key difference between lists and tuples?

Lists and tuples are both sequence data types.

Lists are represented with square brackets [ ] , while tuples are represented with parentheses.

The key difference between the two is that, lists can be modified or appended but tuples cannot be modified or appended.

 

7) Can you name ten built-in functions in Python?

print() – prints the output on the screen

float() – returns a floating point number

int() – returns an integer number

len() – returns the length of an object

input() – prompts for taking user input

list() – returns a list

abs() – returns the absolute value of a number

round() – rounds a number

type() – returns the type of an object

str() – returns a string object

 

8) How would you round a number to 2 decimal places?

x=8.54362

round(x,2)

output: 8.54

9) Name the libraries you have used while working on data?

Some of the libraries that are used while working on data are:

pandas (to work on data: cleansing, preparation, etc.O

numpy (to work on ndarray)

sklearn (for macine learning)

matplotlib (plotting data)

datetime (to deal with date and time)

10) What is the difference between loc and iloc?

Both loc and iloc are used for data selection operation on dataframs. 

loc is label-bases while iloc is integer index based. 

Which means, while using loc we have to specify rows and columns based on their row and column labels.  

While using iloc, we need to specify rows and columns by their integer index. 

Example:

df.loc[‘city’]

df.iloc[5]

11) How will you get all the keys from the dictionary?

print(dict.keys()) 

12) How will you get all the values from the dictionary?

print(dict.values()) 

13) How will capitalize the first letter of a string?

stu=’john’

stu=stu.capitalize()

print(stu) #output: John

 

15) What is the difference between concat() and append()?

pd.concat() is used to combine (bind) the columns in a dataframe while appent is used to add (append) data in the dataframe,

16) List the useful methods that are used while working on data in pandas?

Some of the useful methods are:

read_excel()

read_csv()

describe()

head()

tail()

to_excel()

 

 

17) What is the difference between a function and a method?

A function is a block of code that performs a specific task.

example:

print(“Hello Python”)  #print is a function

A method is like a Python function but it is called on an object.

example: 

city=”Bangalore”

city.upper() #upper is a method used on city object

 

 

Related

Post navigation

Previous Post
Next Post

Leave A Comment Cancel reply

All fields marked with an asterisk (*) are required

Related Posts

  • 5 Key Reasons Why Data Analytics is Important to Business
    September 26, 2023
  • Elevate Your Career with Data Science Jobs: A Complete Guide
    September 26, 2023
  • Is AI Engineering a Good Career Option in 2023 ?
    September 26, 2023
  • Ultimate Guide to Statistical Analysis for Data Science
    September 16, 2023
  • Unlocking Insights: Exploring the Essence of Data Science
    August 15, 2023
  • Power BI Interview Questions and Answers
    August 3, 2023
  • Top 50 Data Science Interview Questions with Answers
    September 7, 2022
  • Excel Interview Success: Top 40 Questions and How to Answer Them
    July 5, 2022
  • SQL Interview Questions and Answers
    June 20, 2022
  • 12 Must Know Problem Solving Questions Asked in Analytics Interview
    May 8, 2022
  • Tableau Interview Question and Answers in 2023
    April 1, 2021
  • Python Interview Questions
    April 1, 2021
  • Python codes for interview preparation
    April 1, 2021
  • Python Programming – Fundamental codes for logic development
    April 1, 2021

Introtallent

Best Data Science training institute in Bangalore.

Follow Us

Contact Us

  • #10, First Floor, 12th Cross, CMH Road, Indiranagar, Bangalore 560037

  • [email protected]

  • +91 843 161 0064

Feel free to contact us.
  • About Us
  • Analytics Training
  • Artificial Intelligence Course
  • Blog
  • Data Science PRO
  • Hire from us
  • Home
  • Introtallent in News
  • Privacy Policy
  • Student Registration
  • Tableau Course
 © 2017-2023 Introtallent . All Rights Reserved