conditional-statements

Write a program to sum all the integers between 1 and 1000, that are divisible by 13, 15 or 17, but not by 30 [closed]

和自甴很熟 提交于 2020-06-29 08:57:08
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Improve this question This my code i don't know what to do next I'm totally beginner int number = lb; while(number <= ub){ if (number % 7 == 0 && number % 15 == 0 && number % 17 == 0 && number % 30 != 0 ){ sum+= number; } number++; } System.out.println("Answer: " + sum); } } 回答1: You have to do

SQL: Set conditional value based on varying criteria in another table

扶醉桌前 提交于 2020-06-29 03:22:32
问题 A bit new to SQL - the db is Snowflake, which I believe is ANSI Main table shown below. Combinations of same Issue/UPC/Warehouse/Date can be possible, since a new record is added whenever a new issue is reported. Other columns exist, but should not affect this question The exclude column is what I'm trying to figure out - it should be 'Y' if the desired combination of Issue/UPC/Warehouse and Date is in the Exclusion table, shown below. The tricky part is the LEVEL column, defining if a UPC

SQL: Set conditional value based on varying criteria in another table

↘锁芯ラ 提交于 2020-06-29 03:22:09
问题 A bit new to SQL - the db is Snowflake, which I believe is ANSI Main table shown below. Combinations of same Issue/UPC/Warehouse/Date can be possible, since a new record is added whenever a new issue is reported. Other columns exist, but should not affect this question The exclude column is what I'm trying to figure out - it should be 'Y' if the desired combination of Issue/UPC/Warehouse and Date is in the Exclusion table, shown below. The tricky part is the LEVEL column, defining if a UPC

Using Pandas to Filter String In Cell with Multiple Values

耗尽温柔 提交于 2020-06-27 11:57:49
问题 I am using pandas to filter a data frame using str.contains() but my logic is dropping values that I might want to keep given the string. I don't know how to use Pandas to sort this out. A sample cell in the excel sheet that I am working with would look like: Case #1: Don't flag this because there is a different recipient, bob@gmail.com Recipient --------- joe@work.com, bob@gmail.com, sally@work.com Case #2: Flag this because every recipient contains @work.com Recipient --------- mike@work

Applying mutate_at conditionally to specific rows in a dataframe in R

别等时光非礼了梦想. 提交于 2020-06-23 04:11:09
问题 I have a dataframe in R that looks like the following: a b c condition 1 4 2 acap 2 3 1 acap 2 4 3 acap 5 6 8 ncap 5 7 6 ncap 8 7 6 ncap I am trying to recode the values in columns a, b, and c for condition ncap (and also 2 other conditions not pictured here) while leaving the values for acap alone. The following code works when applied to the first 3 columns. I am trying to figure out how I can apply this only to rows that I specify by condition while keeping everything in the same dataframe

Check if multiple values are all false or all true

淺唱寂寞╮ 提交于 2020-06-22 05:18:48
问题 How can I check if 20 variables are all true, or if 20 variables are all false? if possible without using a really long if ... the variables are actually array elements: array('a'=> true, 'b'=> true ...) to make it more clear: if the array has both true and false values return nothing if the array has only true values return true if the array has only false values return false :) 回答1: if(count(array_unique($your_array)) === 1) return current($your_array); else return; 回答2: You could use in

How to add a condition to a variable - GAMS

情到浓时终转凉″ 提交于 2020-06-14 08:34:13
问题 In the model I'm trying to build, I have a variable defined as: Variables x(i,j) number of motors produced in month i to be delivered in month j ; In that variable, j must always be equal or greater than i for it to make sense (you can't produce something in this month to be delivered in the previous month). However, I have no clue as to how I can properly model this. I've searched and couldn't find an easy solution to this. Any ideas? 回答1: You should use "variables with limited domains" for

Using time and numerical value in conditional statements to create categorical column python

99封情书 提交于 2020-06-03 19:29:54
问题 I'm trying to execute if statement using time and numerical value to make a new column categorical column Condition - if time is between 05:00:00 and 19:00:00 and t_value > 0 & t_value <=13 then classify as "C" else "IC" If time is not in the range then classify as NA Example Input t_value 2020-05-17 00:00:00 0 2020-05-17 01:00:00 0 2020-05-17 02:00:00 0 2020-05-17 03:00:00 0 2020-05-17 04:00:00 0 2020-05-17 05:00:00 0 2020-05-17 06:00:00 0 2020-05-17 07:00:00 8 2020-05-17 08:00:00 9 2020-05

Using time and numerical value in conditional statements to create categorical column python

旧街凉风 提交于 2020-06-03 19:28:21
问题 I'm trying to execute if statement using time and numerical value to make a new column categorical column Condition - if time is between 05:00:00 and 19:00:00 and t_value > 0 & t_value <=13 then classify as "C" else "IC" If time is not in the range then classify as NA Example Input t_value 2020-05-17 00:00:00 0 2020-05-17 01:00:00 0 2020-05-17 02:00:00 0 2020-05-17 03:00:00 0 2020-05-17 04:00:00 0 2020-05-17 05:00:00 0 2020-05-17 06:00:00 0 2020-05-17 07:00:00 8 2020-05-17 08:00:00 9 2020-05

Drop dates based on condition in python

↘锁芯ラ 提交于 2020-06-01 06:57:05
问题 I'm trying to implement a condition where if the count of incorrect values is greater than 2 (2019-05-17 & 2019-05-20 in the example below) then the complete date (all the time blocks) is removed Input t_value C/IC 2019-05-17 00:00:00 0 incorrect 2019-05-17 01:00:00 0 incorrect 2019-05-17 02:00:00 0 incorrect 2019-05-17 03:00:00 4 correct 2019-05-17 04:00:00 5 correct 2019-05-18 01:00:00 0 incorrect 2019-05-18 02:00:00 6 correct 2019-05-18 03:00:00 7 correct 2019-05-19 04:00:00 0 incorrect