Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Python Interview Questions You'll Most Likely Be Asked
Python Interview Questions You'll Most Likely Be Asked
Python Interview Questions You'll Most Likely Be Asked
Ebook118 pages1 hour

Python Interview Questions You'll Most Likely Be Asked

Rating: 2 out of 5 stars

2/5

()

Read preview

About this ebook

  • 215 Python Interview Questions
  • 78 HR Interview Questions 
  • Real life scenario based questions
  • Strategies to respond to interview questions
  • 2 Aptitude Tests

 

Python

LanguageEnglish
Release dateSep 7, 2017
ISBN9781946383839
Python Interview Questions You'll Most Likely Be Asked

Read more from Vibrant Publishers

Related to Python Interview Questions You'll Most Likely Be Asked

Titles in the series (33)

View More

Related ebooks

Programming For You

View More

Related articles

Reviews for Python Interview Questions You'll Most Likely Be Asked

Rating: 2 out of 5 stars
2/5

1 rating0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Python Interview Questions You'll Most Likely Be Asked - Vibrant Publishers

    Python

    Interview Questions

    You'll Most Likely Be Asked

    Job Interview Questions Series

    www.vibrantpublishers.com

    *****

    Python Interview Questions You'll Most Likely Be Asked

    Copyright 2021, By Vibrant Publishers, USA. All rights reserved. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior permission of the publisher.

    This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. The author has made every effort in the preparation of this book to ensure the accuracy of the information. However, information in this book is sold without warranty either expressed or implied. The Author or the Publisher will not be liable for any damages caused or alleged to be caused either directly or indirectly by this book.

    Vibrant Publishers books are available at special quantity discount for sales promotions, or for use in corporate training programs. For more information please write to bulkorders@vibrantpublishers.com

    Please email feedback / corrections (technical, grammatical or spelling) to spellerrors@vibrantpublishers.com

    To access the complete catalogue of Vibrant Publishers, visit www.vibrantpublishers.com

    *****

    Table of Contents

    1. General Python Concepts

    2. Python Looping

    3. Python Conditionals

    4. String Manipulation

    5. Python Data Types

    6. File Manipulation

    7. Python Thread Management

    8. Python Database Interface

    9. Python Internet Communication

    10. HTML/XML in Python

    HR Interview Questions

    INDEX

    *****

    Python

    Interview Questions

    Review these typical interview questions and think about how you would answer them. Read the answers listed; you will find best possible answers along with strategies and suggestions.

    *****

    General Python Concepts

    1: How is Python executed?

    Answer:

    Python files are compiled to bytecode, which is then executed by the host.

    Alternate Answer: Type python .py at the command line.

    2: What is the difference between .py and .pyc files?

    Answer:

    .py files are Python source files. .pyc files are the compiled bytecode files that are generated by the Python compiler.

    3: How do you invoke the Python interpreter for interactive use?

    Answer:

    python or pythonx.y

    where x.y are the version of the Python interpreter desired.

    4: How are Python blocks defined?

    Answer:

    Python blocks are defined by indents or tabs. This is different from most other languages which use symbols to define blocks. Indents in Python are significant.

    5: What is the Python interpreter prompt?

    Answer:

    Three greater-than signs: >>>

    Also, when the interpreter is waiting for more input the prompt changes to three periods ...

    6: How do you execute a Python Script?

    Answer:

    From the command line, type

    python .py or pythonx.y.py

    where x.y is the version of the Python interpreter desired.

    7: Explain the use of try, except, raise, and finally.

    Answer:

    Try, except and finally blocks are used in Python error handling. Code is executed in the try block until an error occurs. One can use a generic except block, which will receive control after all errors, or one can use specific exception handling blocks for various error types. Control is transferred to the appropriate except block. In all cases, the finally block is executed. Raise may be used to raise your own exceptions.

    8: Illustrate the proper use of Python error handling.

    Answer:

    Code Example:

    try:

    ... # This can be any code

    except:

    ... # error handling code goes here

    finally:

    ... # code that will be executed regardless of exception handling goes here.

    9: What happens if an error occurs that is not handled in the except block?

    Answer:

    The program terminates, and an execution trace is sent to sys.stderr.

    10: How are modules used in a Python program?

    Answer:

    Modules are brought in via the import statement.

    11: How do you create a Python function?

    Answer:

    Functions are defined using the def statement. An example might be deffoo(bar):

    12: How is a Python class created?

    Answer:

    Classes are created using the class statement. An example might be class aardvark(foobar):

    13: How is a Python class instantiated?

    Answer:

    The class is instantiated by calling it directly. An example might be myclass=aardvark(5)

    14: In a class definition, what does the __init__() function do?

    Answer:

    It overrides the any initialization from an inherited class, and is called when the class is instantiated.

    15: How does a function return values?

    Answer:

    A Function returns values using the return statement.

    16: What happens when a function doesn’t have a return statement? Is this valid?

    Answer:

    Yes, this is valid. The function will then return a None object. The end of a function is defined by the block of code being executed (i.e., the indenting), not by any explicit keyword.

    17: What is the lambda operator?

    Answer:

    The lambda operator is used to create anonymous functions. It is mostly used in cases where one wishes to pass functions as parameters, or assign them to variable names.

    18: Explain the difference between local and global namespaces.

    Answer:

    Local namespaces are created within a function, when that function is called. Global name spaces are created when the program starts.

    19: Name the four main types of namespaces in Python.

    Answer:

    a) Global

    b) Local

    c) Module and

    d) Class namespaces

    20: When would you use triple quotes as a delimiter?

    Answer:

    Triple quotes " or ‘’’ are string delimiters that can span multiple lines in Python. Triple quotes are usually used when spanning multiple lines, or enclosing a string that has a mix of single and double quotes contained therein.

    *****

    Python

    Enjoying the preview?
    Page 1 of 1