#### Category : coding-style

I wanted to get permutations of a list of numbers without using any external library. I have written the code below class Solution: def permute(self, nums: List[int] , s = 0 , ans = [] ) -> List[List[int] ]: l = len(nums) if l == 0: return 0 if l == 1: return [nums] if ..

Create a function that returns the thickness (in meters) of a piece of paper after folding it n number of times. The paper starts off with a thickness of 0.5mm. def num_layers(a): Sum=0 for i in range(-1,100): for k in range(1,a+1): Sum+=2**i if k==a+1: break return (Sum)/1000 Where am I going wrong?I have written it ..

Q:- Create a function based on the input and output. Look at the examples, there is a pattern.(Please check the link as I am unable to post examples here.) Example: Page of the question along with required output. My code def secret(a): b=a[:-2] a_list=list(a) last_number=int(a_list[-1]) Final_recurr=last_number+last_number d="{} ".format(b)*Final_recurr j=d.split() for i,k in enumerate(j): if int(i)%2!=0: ..

i have 3 character type columns in my table has time format values i.e while processing (in python 3.7) to in if condition i am using following statement; t1 = ’09:12′ t2 = ’09:10′ t3 = ’20:00′ if datetime.strptime(t1, ‘%H:%M’) > datetime.strptime(t2, ‘%H:%M’): print((datetime.strptime(t1, ‘%H:%M’) – datetime.strptime(t2, ‘%H:%M’))) # above prints 00:02 but i need ..

I want styling output log, but im have small problem with color this is what i do and my python code is def xprint_info(self, info, bold=False): jam = datetime.datetime.fromtimestamp(time.time()).strftime(‘%H:%M:%S’) jam = colored(jam, ‘cyan’) if bold: header = colored(‘INFO’, ‘green’,attrs=[‘bold’]) info = colored(info, ‘white’, attrs=[‘bold’]) else: header = colored(‘INFO’, ‘green’) info = colored(info, ‘white’) text = ..

I have a code for analyzing biasness in dataset using aequitas. I have been asked to use pythondotenv in it and I don’t know how to do it. I have studied different resources and I am able to install pythondotenv, but still I don’t know how to use it.Can anyone suggest me how to use ..

i have to get my number in 10-length that is how can I get following results in python if my digits are 1 than it should print 9 zeros and 1 that is 0000000001, if my number is 277 than it should add 7 zeros in start that 0000000277, if 33 than it should print ..

I am getting this error when I run the command: from shapely.geometry import LineString Error: Could not find module ‘C:UsersSWWBAnacondaLibrarybingeos_c.dll’ (or one of its dependencies). Try using the full path with constructor syntax. how can I solve it? Source: Python..

grid = [[‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’], [‘.’, ‘O’, ‘O’, ‘.’, ‘.’, ‘.’], [‘O’, ‘O’, ‘O’, ‘O’, ‘.’, ‘.’], [‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘.’], [‘.’, ‘O’, ‘O’, ‘O’, ‘O’, ‘O’], [‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘.’], [‘O’, ‘O’, ‘O’, ‘O’, ‘.’, ‘.’], [‘.’, ‘O’, ‘O’, ‘.’, ‘.’, ‘.’], [‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ..

I want to convert this into a more readable for other programmers in the team, but I am not sure how properly refactor this function that merges two dict, and remove duplicates based on value def mergeDict(json1, json2): cveids = set([n[‘id’] for n in json1]).union(set([n[‘id’] for n in json2])) jf1={s[‘id’]:s[‘url’] for s in json1} jf2={s[‘id’]:s[‘url’] ..