Below are 6 simple Python Programming Language questions which can be asked in a Python Related job interview.
Q. 1 – Explain Python Utility Functions.
isdigit() => Returns true if string contains only digits, returns false otherwise.
islower() => Returns true if string has at least 1 cased character and all cased characters are in lowercase, returns false otherwise.
isnumeric() => Returns true if a unicode string contains only numeric characters, returns false otherwise.
isspace() => Returns true if string contains only whitespace characters, returns false otherwise.
isupper() => Returns true if string has at least one cased character and all cased characters are in uppercase, returns false otherwise.
lower() => Converts all uppercase letters in string to lowercase.
lstrip() => Removes all leading whitespace from string.
rstrip() => Removes all trailing whitespaces from string.
max(str) => Returns the max alphabetical character from the string str.
replace(old, new [, max]) => Replaces all occurrences of old in string with new or at most max occurrences if max given.
strip([chars]) => Performs both lstrip() and rstrip() on string.
swapcase() => Inverts cases for all characters in string — Changes Uppercase Letters to Lower and vice-versa.
Q. 2 – How to check if two Python Strings are Equal?
Python Operator == can be used for checking whether strings are equal or not. If strings are same then string1 == string2 will return True, otherwise will return False.
Q. 3 – Explain Type Conversions of Collection Types in Python.
Convert From | Convert To | Syntax | Example |
---|---|---|---|
List | Set | set(list) | set([1, 2, 3]) will be {1, 2, 3} |
Set | Tuple | tuple(set) | tuple({1, 2, 3}) will be (1, 2, 3) |
Nested List | Dictionary | dict(nested list) | dict([[1, 2], [3, 4]]) will be {1: 2, 3: 4} |
Set | List | list(set) | list({1, 2, 3}) will be [1, 2, 3] |
Q. 4 – What are Set Operations in Python Programming Language.
Set Operation | Description | Syntax | Example |
---|---|---|---|
isdisjoint | Returns True if two sets don’t have anything in common | A.isdisjoint(B) | {1, 2, 3}.isdisjoint({3, 4, 5}) Returns True |
issubset | Returns True if A is subset of B | A.issubset(B) | {1, 2}.issubset({91, 23}) Returns False |
intersection | Returns a set containing common elements between two sets | A.intersection(B) | {1, 2, 3, 4}.intersection({1}) Returns {1} |
Q. 5 – What is Frozenset?
A Python Set which is immutable is known as Frozenset.
Q. 6 – Explain what are Python Functions?
A function is a group of statements intended to do particular task. In Python we can define functions by using keyword def.
def fun():
print("I'm preparaing for Python Developer job interview")
No Comments
Leave a comment Cancel