September 25, 2018

Sreekanth B

Huawei Python Recent Asked Interview Questions Answers

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]
>>>print dict[Angel]

Huawei Python Recent Asked Interview Questions Answers
Huawei Python Recent Asked Interview Questions Answers
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 Programming Paradigm does Python supports?

Python supports both Procedural Programming approach as well as Object Oriented Programming Approach. Moreover, you can use both the approaches in a single Python program.

How to take input from the User in Python?

Python provides a built-in method to accept input from the user.
It is as follows: input(“Enter the Input”)
However, in order to store the input in a variable, you must write a variable name before the input() method.
It can done as follows: var1=input(“Enter the input”)

How to terminate a line of code in Python?

Python is an extremely efficient and easy to use language. You can terminate a Python line of code using a Semi-Colon. However, it is not mandatory to use a Semi-colon at the end of every line. It is up to you if you want to use it or not.

Enlist Popular Frameworks of Python?

Major Frameworks: Django and Pyramid

Minor Frameworks: Bottle and Flask

What is Lambda in Python specification?

It is a single expression which is an Anonymous Method often used as Inline function.

Enlist the Applications of Python Programming?

1. Web Application Development and Web Frameworks such as DJango and Pyramid.
2. Game Development
3. Desktop Based Applications
4. Micro Frameworks such as Bottle and Flask

How do you create a Text Box Element in Python?

The Text Box Class is available in Tkinter Module. We first need to import it and then we can take in a frame label by the following command:

text1 = Text(frame1, width = 35, height = 5)

text1 is a variable to hold the Text Element and frame1 is the the name of the Frame variable onto to which we want to adjust our Text Box. It has two parameters viz., width and height that defines its dimensions.
It is mandatory to define the Frame first.

Enlist some of GUI Elements in Python Tkinter module?

Frame, Label, Text Entry, Check Button, Radio Button, Text Box are some of the few Tkinter GUI Elements used in Python.

Which method is used to set the file pointer at a particular location?

The seek() method is used to set the File pointer to a particular position in the Text File. It takes in two parameters out of which the first one is mandatory and the second one is optional.


seek(location, source)

How Does The Ternary Operator Work In Python?

The ternary operator is an alternative for the conditional statements. It combines of the true or false values with a statement that you need to test. The syntax would look like the one given below.

[onTrue] if [Condition] else [onFalse]

x, y = 35, 75
smaller = x if x < y else y

What Does The <Self> Keyword Do?

The <self> keyword is a variable that holds the instance of an object. In almost, all the object-oriented languages, it is passed to the methods as hidden parameter.

How will you convert a string to a long in python?

long(x [,base] ) – Converts x to a long integer. base specifies the base if x is a string.

How will you convert an integer to a character in python?

chr(x) − Converts an integer to a character.

How will you convert an integer to an unicode character in python?

unichr(x) − Converts an integer to a Unicode character.

Subscribe to get more Posts :