• info@introtallent.com
  • +91 8431610064
Introtallent
  • Courses
    • Data Science PRO [OFFLINE]
    • Data Science PRO [Live Online]
    • Analytics PRO [Live Online]
    • AI Engineer Certificate [Live Online]
  • Hire From Us
  • Student
    • Download Android App
    • 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

  • April 1, 2021June 23, 2022

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

 

 

Share this:

  • Facebook
  • X

Related

Post navigation

Previous Post
Next Post

Leave A Comment Cancel reply

All fields marked with an asterisk (*) are required

Related Posts

  • Understanding the Differences Between Data Science and Data Analytics
    December 17, 2024
  • Key Data Science and AI Trends to Watch in 2025
    November 5, 2024
  • Mastering the XLOOKUP Function in Excel: Step-by-Step
    June 2, 2024
  • The Rise of AI in Business Analytics For Decision-Making
    May 11, 2024
  • What Is Generative AI And How Does It Work? A Comprehensive Guide
    April 12, 2024
  • Machine Learning: A Beginner’s Guide to Understanding the Basics
    April 12, 2024
  • 9 Steps for Crafting an Ultimate Data Scientist Resume
    March 16, 2024
  • Data Science Career Opportunities: Your Guide To Unlock Top Data Scientist Jobs
    December 31, 2023
  • Best Career Options After Pursuing Data Science Course
    December 30, 2023
  • Harness the Power of Data with Six Captivating Tableau Projects
    December 29, 2023
  • Definitive List of Top 10 Data Science Tools
    December 28, 2023
  • Top 15 Data Science Interview Questions You Must Nail!
    November 30, 2023
  • How to Become a Data Scientist in Bangalore?
    November 30, 2023
  • Impact of Data Science in Business and Its Uses
    November 30, 2023
  • Essential Role of Data Scientist in Today’s Tech Landscape
    November 30, 2023
  • 5 Transformative Benefits of Tableau Certification to Boost Career
    October 24, 2023
  • Types of Artificial Intelligence Categories You Must Familiarize With
    October 23, 2023
  • Exploring the Need for Data Science and AI Experts in 2023
    October 20, 2023
  • What Does a Data Analyst Do: Roles, Skills, and Salary?
    October 20, 2023
  • 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
  • What is Data Science – A complete overview with future
    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 with Answers – An Ultimate Guide
    June 20, 2022
  • 12 Must Know Problem Solving Questions Asked in Analytics Interview
    May 8, 2022
  • 17 Ultimate Non-Tech Interview Questions to Empower Your Career Path
    May 2, 2021

Introtallent

Best Data Science
training institute
in Bangalore.

Follow Us

Contact Us

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

  • info@introtallent.com

  • +91 843 161 0064

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