Explain how python is interpreted ?
- Python program runs directly from the source code.
- Each time Python programs are executed code is required.
- Python converts source code written by the programmer into intermediate language which is again translated into the native language / machine language that is executed. So Python is an Interpreted language.
- It is processed at runtime by the interpreter.
- The program need not be compiled before its execution.
- It is similar to PERL and PHP.
- Python is also interactive where it can prompt and interact with the interpreter directly to write the programs.
- It supports the object-oriented style of the technique which encapsulates the code within the objects.
Explain the dictionary in Python ?
Python's built-in data type is dictionary, which defines one-to-one relationships between keys and values.
Dictionaries consist of pairs of keys and their corresponding values.
Dictionaries are indexed by keys.
Dictionary is similar to associative array or hash table of other languages.
As following example explains further- India, Angel & Cartoon are keys & their corresponding values are Bharat, Teresa & Mickey respectively.
>>> dict = {'India': 'Bharat', 'Angel': ‘Teresa’, 'Cartoon': 'Mickey'}
>>>print dict[India]
Bharat
>>>print dict[Angel]
Teresa.
What is the output of print list if list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ]?
It will print concatenated lists. Output would be [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ].
What is the output of print list[0] if list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ]?
It will print first element of the list. Output would be abcd.
What is the output of print list + tinylist * 2 if list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ] and tinylist = [123, ‘john’]?
It will print concatenated lists. Output would be [‘abcd’, 786, 2.23, ‘john’, 70.2, 123, ‘john’, 123, ‘john’].
What is tuples in Python?
A tuple is another sequence data type that is similar to the list. A tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
What is the difference between tuples and lists in Python?
The main differences between lists and tuples are − Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. Tuples can be thought of as read-only lists.
What is the output of print tuple if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
It will print complete tuple. Output would be (‘abcd’, 786, 2.23, ‘john’, 70.200000000000003).
What is the output of print tuple[0] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
It will print first element of the tuple. Output would be abcd.
Name some of the features of Python.
Following are some of the salient features of python
It supports functional and structured programming methods as well as OOP.
It can be used as a scripting language or can be compiled to byte-code for building large applications.
It provides very high-level dynamic data types and supports dynamic type checking.
It supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
Do you have any personal projects?
Really?
This shows that you are willing to do more than the bare minimum in terms of keeping your skillset up to date. If you work on personal projects and code outside of the workplace then employers are more likely to see you as an asset that will grow. Even if they don’t ask this question I find it’s useful to broach the subject.
Is python a case sensitive language?
Yes! Python is a case sensitive programming language.
What are the supported data types in Python?
Python has five standard data types −
Numbers
String
List
Tuple
Dictionary
What is the output of print str if str = ‘Hello World!’?
It will print complete string. Output would be Hello World!.
What is the output of print str[0] if str = ‘Hello World!’?
It will print first character of the string. Output would be H.
What is the output of print tuple + tinytuple if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2) and tinytuple = (123, ‘john’)?
It will print concatenated tuples. Output would be (‘abcd’, 786, 2.23, ‘john’, 70.200000000000003, 123, ‘john’).
What are Python’s dictionaries?
Python’s dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.
- Python program runs directly from the source code.
- Each time Python programs are executed code is required.
- Python converts source code written by the programmer into intermediate language which is again translated into the native language / machine language that is executed. So Python is an Interpreted language.
- It is processed at runtime by the interpreter.
- The program need not be compiled before its execution.
- It is similar to PERL and PHP.
- Python is also interactive where it can prompt and interact with the interpreter directly to write the programs.
- It supports the object-oriented style of the technique which encapsulates the code within the objects.
Explain the dictionary in Python ?
Python's built-in data type is dictionary, which defines one-to-one relationships between keys and values.
Dictionaries consist of pairs of keys and their corresponding values.
Dictionaries are indexed by keys.
Dictionary is similar to associative array or hash table of other languages.
As following example explains further- India, Angel & Cartoon are keys & their corresponding values are Bharat, Teresa & Mickey respectively.
>>> dict = {'India': 'Bharat', 'Angel': ‘Teresa’, 'Cartoon': 'Mickey'}
>>>print dict[India]
Bharat
>>>print dict[Angel]
Teresa.
What is the output of print list if list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ]?
It will print concatenated lists. Output would be [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ].
CDW Most Frequently Asked Latest Python Interview Questions Answers |
What is the output of print list[0] if list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ]?
It will print first element of the list. Output would be abcd.
What is the output of print list + tinylist * 2 if list = [ ‘abcd’, 786 , 2.23, ‘john’, 70.2 ] and tinylist = [123, ‘john’]?
It will print concatenated lists. Output would be [‘abcd’, 786, 2.23, ‘john’, 70.2, 123, ‘john’, 123, ‘john’].
What is tuples in Python?
A tuple is another sequence data type that is similar to the list. A tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.
What is the difference between tuples and lists in Python?
The main differences between lists and tuples are − Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. Tuples can be thought of as read-only lists.
What is the output of print tuple if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
It will print complete tuple. Output would be (‘abcd’, 786, 2.23, ‘john’, 70.200000000000003).
What is the output of print tuple[0] if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )?
It will print first element of the tuple. Output would be abcd.
Name some of the features of Python.
Following are some of the salient features of python
It supports functional and structured programming methods as well as OOP.
It can be used as a scripting language or can be compiled to byte-code for building large applications.
It provides very high-level dynamic data types and supports dynamic type checking.
It supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
Do you have any personal projects?
Really?
This shows that you are willing to do more than the bare minimum in terms of keeping your skillset up to date. If you work on personal projects and code outside of the workplace then employers are more likely to see you as an asset that will grow. Even if they don’t ask this question I find it’s useful to broach the subject.
Is python a case sensitive language?
Yes! Python is a case sensitive programming language.
What are the supported data types in Python?
Python has five standard data types −
Numbers
String
List
Tuple
Dictionary
What is the output of print str if str = ‘Hello World!’?
It will print complete string. Output would be Hello World!.
What is the output of print str[0] if str = ‘Hello World!’?
It will print first character of the string. Output would be H.
What is the output of print tuple + tinytuple if tuple = ( ‘abcd’, 786 , 2.23, ‘john’, 70.2) and tinytuple = (123, ‘john’)?
It will print concatenated tuples. Output would be (‘abcd’, 786, 2.23, ‘john’, 70.200000000000003, 123, ‘john’).
What are Python’s dictionaries?
Python’s dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.
Post a Comment