Contents
- 1 Python Interview Questions
- 1.1 What is Script?
- 1.2 Why Python programming language?
- 1.3 What is the difference between Script and Program?
- 1.4 What is Compiler?
- 1.5 Can we modify a list?
- 1.6 Click here to Learn Python Online Training
- 1.7 Can we modify a tuple?
- 1.8 Can we modify a tuple element?
- 1.9 Can we store a List inside Tuple?
- 1.10 Differentiate Compilation and Interpretation?
- 1.11 What is the return type of input() function?
- 1.12 How can we process the input values in application?
- 1.13 What is the use of ‘pass’ keyword?
- 1.14 What is break statement?
- 1.15 Differentiate Break and Continue?
- 1.16 Can we store a Tuple inside List?
- 1.17 Can we store a set inside another set?
- 1.18 Click here to Learn Python Online Training
Python Interview Questions
What is Script?
- A program that serves the application (Standalone or Web) that was developed using another programming language.
- Script is a set of instructions that will be interpreted.
- Script carried out by another program rather than by the computer processor.
Why Python programming language?
- Every programming language has its scope. Different programming languages used for different types of application development.
- Python script analyzes the data effectively using its pre-defined functionality than other programming codes.
- Python can be used in web development, Gaming development, Embedded System applications and many more.
What is the difference between Script and Program?
- A Program (Process) is a set of instructions.
- A script is a sub program or sub process.
What is Compiler?
- A translator that converts the source code (high level instructions set) into either machine code or interpreter understandable code.
Can we modify a list?
Yes, List is mutable collection object. Hence we can modify the object by adding or removing the elements once it has been created.
Click here to Learn Python Online Training
Can we modify a tuple?
- No, tuple is immutable object.
- Immutable objects are constants hence we cannot modify once it has created.
Can we modify a tuple element?
- Tuple elements can be Mutable or Immutable.
- If the element is Mutable like List, we can modify.
- If the element is immutable like int, float , string and Tuple cannot be modified.
Can we store a List inside Tuple?
Yes allowed.
Tuple can able to store both Mutable and Immutable objects.
List is Mutable hence that cannot be stored as an element.
Differentiate Compilation and Interpretation?
- Compiler translates the source code into machine code all at once only if all instructions are syntactically correct.
- Interpreter translates the code line by line and generates the output for translated instruction instantly.
What is the return type of input() function?
- Input() function reads the end user input in the program.
- It returns the input values in String format.
How can we process the input values in application?
- We can convert the String type elements into corresponding type using pre-defined data conversion methods such as int() , float() ….
What is the use of ‘pass’ keyword?
- ‘pass’ keyword is used to define empty blocks, functions and classes.
What is break statement?
“Break” is used to terminate the flow of a loop.
Differentiate Break and Continue?
“Break” is used to terminate the loop completely where as “Continue” is used to end the current iteration and continue with remaining iterations execution.
Can we store a Tuple inside List?
List allows both Mutable and Immutable objects as elements.
Tuple is Immutable and it can be stored as an element.
Can we store a set inside another set?
No.
Set is Mutable.
Set elements must be immutable.