[Solved] Is it possible to do this in Java? [closed]

Here is the closest code: public class Stackoverflow_03262019 { public static void main(String[] args) { int[] arr=new int[5]; Arrays.fill(arr,0); Arrays.stream(arr).forEach(val-> System.out.println(val)); } } “` You can add any value instead of 0; 2 solved Is it possible to do this in Java? [closed]

[Solved] Python : Remove all values from a list in between two values

EDIT: Sorry, misread your question. I thought you only wanted to keep these values. Changed my code accordingly. list1 = [“13:00″,”13:10″,”13:20″,”13:30″,”13:40”] range_start = “13:10” range_end = “13:30” You can use list comprehension with the range condition: list1 = [x for x in list1 if not(range_start<=x<=range_end)] print(list1) You could also use filter on your list: list1=list(filter(lambda … Read more

[Solved] Python List of Dictionaries by Loops

If you want only print the resulting dictionaries, uncomment the print statement (and comment the following 2). d1 = [ {‘index’:’1′,’color’:’red’}, {‘index’:’2′,’color’:’blue’}, {‘index’:’3′,’color’:’green’} ] d2 = [ {‘device’:’1′,’name’:’x’}, {‘device’:’2′,’name’:’y’}, {‘device’:’3′,’name’:’z’} ] result_list = [] for dict1 in d1: merged_dict = dict1.copy() for dict2 in d2: merged_dict.update(dict2) # print(merged_dict) result_list.append(merged_dict.copy()) print(result_list) The result: [{‘name’: ‘x’, ‘device’: … Read more

[Solved] How to make every ‘beginner’ shown at random during the run of the program [closed]

So this isn’t exactly an answer for the specific way you decided to go about this program but this is a much simpler way: from random import randrange def beginner_addition(): A = randrange(1,11) # Increase range on harder questions B = randrange(1,11) # Ex. for intermediate_addition(), randrange would be (10,21) maybe… C = A + … Read more

[Solved] Comparing 2 lists without using “in”

>>>l1 = [i for i in range(1,25)] >>>l2 = [i for i in range(24, 50)] >>>[x for x in l1 if x in l2] [24] Sorry I misread. How about this: for i in range(len(l1)): for j in range(len(l2)): if l2[j] == l1[i]: print l2[j] If you need to add matches to a list just … Read more

[Solved] Oops, try again. Your function failed on the message yes. It returned ‘yes’ when it should have returned ‘Shutting down’

Couple of points: Misplaced return statement. Should be at end. if yes(): It is wrong. You want to compare function input with yes. It should be if s == ‘yes’:. Same for rest also. Since you have written function definition as def shut_down(s):, it is expecting one argument. You should pass one argument while calling … Read more

[Solved] How to ‘encrypt’ a file

If your goal is just to exchange the letters in a string with others that you specify, then the solution is the following: decrypted = ‘abcdefghijklmnopqrstuvwxyz’ #normal alphabet encrypted = ‘MNBVCXZLKJHGFDSAPOIUYTREWQ’ #your “crypted” alphabet #Encription text=”cryptme” #the string to be crypted encrypted_text=”” for letter in text: encrypted_text += encrypted[decrypted.find(letter)] print encrypted_text #will print BOWAUFC #Decription … Read more

[Solved] Recovering Python modules

You have to go to the settings in there and if there is no way of finding them then you can go onto the python website and reinstall them from there 🙂 solved Recovering Python modules

[Solved] Merge multiple list of dict with same value in common key [closed]

If you want a more pythonic way: from itertools import groupby from pprint import pprint from collections import ChainMap a = [{‘a’:0,’b’:23}, {‘a’:3,’b’:77}, {‘a’:1,’b’:99}] b = [{‘a’:1,’c’:666}, {‘a’:4,’c’:546}] c = [{‘d’:33,’a’:3}, {‘d’:1111,’a’:4}, {‘d’:76,’a’:1}, {‘d’:775,’a’:0}] d = [{‘a’:2,’e’:12}, {‘a’:4,’e’:76}] dict_list = a + b + c + d # You just need to specify the key … Read more