Posts

Sample Interview Questions

PYTHON Q1: Implement to_bin(n) function - # Given a number as input write a function that returns a # string with binary representation of a positive integer number # We would like you to write the algorithm to generate this # binary representation in string format without library functions def to_bin(n):     # write your code here     return bin_str # Sample test cases to verify functionality assert to_bin(2) == '10' assert to_bin(7) == '111' assert to_bin(45) == '101101' assert to_bin(32) == '100000' assert to_bin(0) == '0' Q2: Implement a function to extract out all string literals from a SQL string return them in a sorted list def extract_string_literals(str):     # write your code here     return str_literal_list # Sample test cases to verify functionality assert extract_string_literals("select * from order where orderid = 'OEHKJHFUI' and product = 'Iphone 5s'") = ['Iphone 5s', 'OEHKJ...