i am new to programming, please tell me, why when im executing my code the timer is literally in the stratosphere?

from multiprocessing import Process, cpu_count import time def counter(num): count = 0 while count < num: count += 1 def main(): a = Process(target=counter, args=(1000000000,)) a.start() a.join() print(‘finished in: ‘, time.perf_counter(), ‘seconds’) if __name__ == ‘__main__’: main() was expecting to work properly, but when i do it my timer goes like this: 692018.2843528 seconds >Solution… Read More i am new to programming, please tell me, why when im executing my code the timer is literally in the stratosphere?

How to create an Python function able to find the smallest multiple of 8 to handle batch jobs?

Lets say the function will receive an list of IDs like: ids = [15, 16, 17] In this scenario the desired OUTPUT should be: 24 Because the ranges will be: 1 to 24 25 to 48 … On first range (1 to 24) will accommodate all the IDs (15, 16, 17) Second example, lets say… Read More How to create an Python function able to find the smallest multiple of 8 to handle batch jobs?

Python unittest that at least one exception is raised

Is there a way to get unittest standard library to check for multiple exceptions? Obviously assertRaises works for a single exception: How do you test that a Python function throws an exception? But I want to test whether at least one error is raised. This feels right, but is not correct: with self.assertRaises(StatisticsError, ZeroDivisionError): #… Read More Python unittest that at least one exception is raised

How to filter with rest api django?

I have this model: class Item(models.Model): category = models.CharField(max_length=255) subcategory = models.CharField(max_length=255) name = models.CharField(max_length=255) amount = models.PositiveIntegerField() def __str__(self) -> str: return self.name serializer: class ItemSerializer(serializers.ModelSerializer): class Meta: model = Item fields = (‘category’, ‘subcategory’, ‘name’, ‘amount’) views.py: @api_view([‘GET’]) def view_items(request): queryset = Item.objects.all() serializer = ItemSerializer(queryset, many=True) # checking for the parameters from… Read More How to filter with rest api django?

Why my keyframes aren´t working as i hover over?

I am trying to do a css animation on different spans as i hover over them but they are not working and i cant figure out why. This is my html: <div className="content"> <h2>Hello, I´m <br/> <span className=’bounce’>M</span> <span className=’bounce’>a</span> <span className=’bounce’>t</span> <span className=’bounce’>e</span> <span className=’bounce’>o </span> <span className=’bounce’>G</span> <span className=’bounce’>h</span> <span className=’bounce’>i</span> <span className=’bounce’>d</span>… Read More Why my keyframes aren´t working as i hover over?

How to instruct CMake to find specific version of Curl

I have built Curl from source and it’s installed in /usr/local/lib/libcurl.so I am now trying to instruct CMake to statically link this version with my application (if dynamic is easier, that’s fine). From other Stackoverflow questions I tried this: option(CURL_STATICLIB "Set to ON to build libcurl with static linking." ON) option(LIBCURL_ENABLE "Enable or disable the… Read More How to instruct CMake to find specific version of Curl

Do i have to initialise a variable in every if else statement in Java?

int outsideTem = 10; String output; if(outsideTem < 0){ //output = "Grab a coat";// i get an error if i comment out this line but why? //System.out.println(output); } else if(outsideTem < 15){ output = "Grab a cardigan"; //System.out.println(output); } else{ output = "HOT!!!"; //System.out.println("HOT!!!"); } System.out.println(output); Getting an error if i comment out the variable… Read More Do i have to initialise a variable in every if else statement in Java?

How to create a subclass of ttk.Button correctly (class function doesnt work)?

I want to create Buttons with a text and define a function that prints me the text on the monitor when i press the button. Everything works well without classes: from tkinter import * from tkinter import ttk def PressButton(): print(FirstButton.cget(‘text’)) root = Tk() root.title("Simple Calculator") ButtonsFrame = ttk.Frame(root,relief= "groove").grid() FirstButton=ttk.Button(ButtonsFrame, text=1, command= PressButton) FirstButton.grid()… Read More How to create a subclass of ttk.Button correctly (class function doesnt work)?