## math.random() and comparison operator clarification

I know Math.random() generates random numbers, my question is: 1.What is going on by comparing it to .5 (or 50%)? 2.How does that trigger the if statement into working? 3.Is Math.random() getting its …

## while loop not working in email password checker (python)

users = { 1: {“first_name”: “Tom”, “last_name”: “Smith”, “email”: “tom@email.com”, “password”: “123123”}, 2: {“…

## Adding items to the list in the list

I have created a code for the exercise that deals 5 cards to 5 players. The cards are to be dealt to the list in the “players” list. I created a while loop in a while loop. This is where my …

## Insert records for the rest of the year starting on current week

I am trying to insert the same record for the rest of the year. Since we are currently in week 13 of 2021, there are a total of 40 weeks remaining (including week 13). Using the following code, I can …

## Adding M0, M1, … Mn between each two elements in a list

I would like to loop through a list, which is called output as shown below: output = [0, 1, 2, 3, 4, 5, 6] But I have to exclude the first and last elements [1, 2, 3, 4, 5] Then I would like to add …

## How to create menu in Python with multiple if statements

I’m trying to create a menu for a POS like system. I have my gift card balances with their numbers and I’m trying to incorporate this in a menu. In the menu for example, if a user click the number ‘1’…

## Disposed JFrame messing up infinite while loop

So I have a program which intakes a few values through a Scanner and then changes a BufferedImage on a JFrame accordingly. The way it changes the frame continues indefinitely through an infinite while …

## Push calculated result from one array to another using loops

I am trying to figure out how to push the result from the array to the empty arrays after using a function to calculate the result, using a for loop and another with a while loop but I don’t …

## Why is firebase statement inside loop being ignored?

I am coding a project using node.js. This project makes use of firebase realtime database, where data can be sent to and read from. Part of my project involves a loop which will constantly read an …

## Is it possible to see if a client is trying to connect a ServerSocket?

I have this loop running in a thread: ServerSocket ss = new ServerSocket(PORT); while (running) { ClientHandler ch = new ClientHandler(ss.accept); } which keeps a ServerSocket running waiting for …