class Library: def__init__(self,listofbooks,libraryname): self.lst = listofbooks self.name = libraryname def displaybook(self): return f"\t\t\t\tWelcome to {self.name} \ \navaliable books are -\n {self.lst}" def lendbook(self,lendname,bookname): if bookname in lst and bookname not in d: print(f"{bookname} lend to {lendname}") d.__setitem__(bookname,lendname) elif bookname in d: lst.remove(bookname) print("Book is not available lend to-",d[bookname],"\nwe only have-",lst) else: print("Book is not in the library we only have-",lst) ...
Let's learn about list comprehensions! You are given three integers and representing the dimensions of a cuboid along with an integer . Print a list of all possible coordinates given by on a 3D grid where the sum of is not equal to . Here, . Please use list comprehensions rather than multiple loops, as a learning exercise. Example All permutations of are: . Print an array of the elements that do not sum to . Input Format Four integers and , each on a separate line. Constraints Print the list in lexicographic increasing order. Sample Input 0 1 1 1 2 Sample Output 0 [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]] Explanation 0 Each variable and will have values of or . All permutations of lists in the form . Remove all arrays that sum to to leave only the valid permutations. Sample Input 1 2 2 2 ...
Comments
Post a Comment
If you have any doubt you ask me in comment section