Here are six python programming interview questions for your next interview.
Questions on Print and Data Types
- How to run simple Python program?
You can show just writing the print statement in Python.
>>> print("My Output is: " out_Data)
Points to Remember: In Python, you need to use double quotes to display the label.
- What are the rules that you need for defining a Variable?
- Must start with letter or “_” (underscore)
- The variable must contain (a-z, A-Z, _, 0-9). No other characters allowed.
- The variable names are case sensitive.
- People follow the Down-Up-Down method.
- You can give all Capital or Small case
- You can give underscores
Points to Remember: Depending on the project people follow some methods.
- What are the Data Types in Python?
Questions on Strings and Arrays
- How to subtract a sub-string from a string? from front to back and back to front?
String follows index positions: 0, 1, 2, 3, 4, 5 etc. Minus calculates position from the last. Here the count starts from “-1”.
Str = 'Strings in Python'
- How to write an array?
Array position starts from 0, 1, 2, 3, …..
import array as arr
my_array = arr.array('i', [76, 4559, 2100, 206, 235])
for i in my_array:
print('Array is: ', i)
Array is: 76
Array is: 4559
Array is: 2100
Array is: 206
Array is: 235
- How to use functions in String Manipulation?
You can use built-in functions to handle strings. Here is the best example:
Str = "Coding is fun" print("Maximum alphabet: ", max(Str)) print("String in Center: ",Str.center(250)) substring = 'i' print("Number of occurrences of substring in Str: ", Str.count(substring))
Maximum alphabet: u
String in Center: Coding is fun
Number of occurrences of substring in Str: 2
Free Online Trainings
Post your answer using Contact us.