# *** Create a set with strings and perform search in set objects = # Print set.

items.add(“Python”) items.add(“coding”) items.add(“tips”) print(items) # ** Output Python Coding Interview Questions # 14) How do you Concatenate Strings in Python? Python Concatenating Example: # See how to use ‘ ’ to concatenate strings.

print(‘Python’ ‘ Interview’ ‘ Questions’) # Output: Python Interview Questions Python Coding Interview Questions # 15) How to generate random numbers in Python?

A) User can convert list into set by using function.

Example: weekdays = [‘sun’,’mon’,’tue’,’wed’,’thu’,’fri’,’sat’,’sun’,’tue’] list As Set = set(weekdays) print(list As Set) output: set([‘wed’, ‘sun’, ‘thu’, ‘tue’, ‘mon’, ‘fri’, ‘sat’]) Python Interview Questions # 6) How to count the occurrences of a perticular element in the list?

A) We can print sum of the numbers starting from 1 to 100 using this code: print sum(range(1,101)) # In Python the range function does not include the end given. # Sum funtion print sum of the elements of range funtion, i.e 1 to 100.

Python Coding Interview Questions # 17) How do you set a global variable inside a function?

if “tips” in objects: print(“These are the best Python coding tips.”) # Use of “not in” keyword.

if “Java tips” not in objects: print(“These are the best Python coding tips not Java tips.”) # ** Output 5 These are the best Python coding tips.

Example: def testgen(index): weekdays = [‘sun’,’mon’,’tue’,’wed’,’thu’,’fri’,’sat’] yield weekdays[index] yield weekdays[index 1] day = testgen(0) print next(day), next(day) Output: sun mon Python Interview Questions # 3) How to convert a list into a string?