if-statement

Array If-And Condition Not Working As Planned {Python}

Array If-And Condition Not Working As Planned {Python} Question: I have a program where, given a sequence of numbers within an array, the goal is to check whether or not no more than one value can be taken out to make the sequence a strictly increasing sequence. One of my conditions is to check whether …

Total answers: 1

Is there a way to make my code more effiecient

Is there a way to make my code more effiecient Question: Hey so I’m a beginner and was just trying out projects to get better so I made a password checker. Just want to see if there is anyway I can make my code neater or more efficient to tips are nice. import re regex …

Total answers: 4

How do I make this user input change the calculation in this if statement?

How do I make this user input change the calculation in this if statement? Question: How do I make this user input change the calculation in this if statement? print("I have information for the following planets:n") print(" 1. Venus 2. Mars 3. Jupiter") print(" 4. Saturn 5. Uranus 6. Neptunen") weight = 185 planet = …

Total answers: 1

Printing "count" of even numbers while-loop with if

Printing "count" of even numbers while-loop with if Question: I am suppose to be able to complete the following in Python… Fill in the blanks to complete the function “even_numbers(n)”. This function should count how many even numbers exist in a sequence from 0 to the given “n” number, where 0 counts as an even …

Total answers: 5

update column values based on length temp dataframes based on source dataframe

update column values based on length temp dataframes based on source dataframe Question: I have a data: ID closed set message_time aaa 22:00 19:00 19:05 aaa 22:00 19:30 19:40 aaa 22:00 20:00 21:00 bbb 23:00 22:00 22:10 ccc 22:00 19:00 19:05 ccc 22:00 19:30 19:40 code is here: import pandas as pd df = pd.DataFrame({ …

Total answers: 1

Why is my game only printing one output when it should be printing

Why is my game only printing one output when it should be printing Question: I am making a guess the number game, however in my if/else statement it is not printing the else instead it is printing the if always regardless of what input I give it. This is my code: print("Welcome to the number …

Total answers: 1

Discord.py recognizing on_message client event, but IF statements not responding

Discord.py recognizing on_message client event, but IF statements not responding Question: I am working on a Discord bot and in this case want the bot to roll a 6 sided die when any user gives the "roll" command. See code below. Oddly enough this was working just fine, but now the print(worked) triggers and the …

Total answers: 1

Implementing Integration Limits when using Numerical Integration

Implementing Integration Limits when using Numerical Integration Question: I’m using numerical integration to model the trajectory of a particle passing through a non-uniform magnetic field. I’m specifically using a Markov Chain Monte Carlo algorithm (Metropolis-Hastings) that allows me to calculate model data in order to fit the actual particle’s data. The issue that I have …

Total answers: 1

Having an issue with conditional after getting strings lower

Having an issue with conditional after getting strings lower Question: I am a noob in coding and still learning the basics. I’ve been messing with the code and I have reached this situation where the code is just broken. I want to make a simple conditional but lowering the input of the user to make …

Total answers: 2

Python : List Comprehensn with IF/ELSE statement

Python : List Comprehensn with IF/ELSE statement Question: I’m looking for an oneliner for this below logic: links (list) variable will contain = [‘**www.google.com/api/1.js**’,’**/path.js**’] url = "mysite.com" valid_links = [url + u for u in links if not urlparse(u).netloc ] This will give me only [‘mysite.com/path.js’] but not ‘www.google.com‘ in the list. I need full …

Total answers: 1