multiple-conditions

multiple conditions with while loop in python

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 04:22:39
问题 I am having problems including multiple statements with while loop in python. It works perfectly fine with single condition but when i include multiple conditions, the loop does not terminate. Am i doing something wrong here? name = raw_input("Please enter a word in the sentence (enter . ! or ? to end.)") final = list() while (name != ".") or (name != "!") or (name != "?"): final.append(name) print "...currently:", " ".join(final) name = raw_input("Please enter a word in the sentence (enter .

How to do the following with doesn't have or other optimized way in laravel

断了今生、忘了曾经 提交于 2019-12-23 01:52:34
问题 I have a thread which gave the answer but later on I found that I was getting limitations: how to get list of users who are not under belongsToMany relation under a table in laravel? so creating a new thread where I do have an answer but now how can I optimize the same with any prebuild functions like doesntHave or something entirely else. below is the code which gives me the list of users who are under a group and not assigned any task. one group can have multiple tasks so only users where

Using a combination of ANDs and ORs in Mongoid

余生颓废 提交于 2019-12-22 07:01:13
问题 I'd like to construct a query of the form: select * from some_table where (field1 = 'x' or field2 = 'y') and (field3 = 'z' or field4 = 'w') From reading the docs, I thought it should look something like this in Mongoid : SomeTable.or({:field1 => 'x'}, {:field2 => 'y'}) .and # or is it .intersect? .or({:field3 => 'z'}, {:field4 => 'w'}) But then that doesn't work - the mongo selector is simply an "$or" of all the fields. What's the correct way to do this? thanks. I'd also appreciate the

basic sql : selecting AVG() values from the same column multiple times in one query, when each wanted AVG() value uses different WHERE clause

核能气质少年 提交于 2019-12-22 04:38:29
问题 I want to get three different average values from one column (value_to_count) inside one table where all of those average values has a different WHERE clause (according to time). Example Data: ###services#### Table service_id value_to_count time ----------- ----------------------- --------- 604 2054 04:04:50 604 3444 05:00:15 604 2122 07:12:50 604 2144 09:10:50 604 2001 13:12:53 602 2011 15:00:12 602 2115 17:22:35 602 1411 20:22:12 602 1611 21:04:52 602 2111 23:43:45 I'm using this query at

Simplify nested case when statement

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 03:35:33
问题 Below is my current SELECT CASE statement: SELECT CASE WHEN edition = 'STAN' AND has9 = 1 THEN '9' WHEN edition = 'STAN' AND has8 = 1 THEN '8' WHEN edition = 'STAN' AND has7 = 1 THEN '7' WHEN edition = 'STAN' AND hasOLD = 1 THEN 'OLD' WHEN edition = 'SUI' AND has_s9 = 1 THEN 'S9' WHEN edition = 'SUI' AND has_s8 = 1 THEN 'S8' ELSE 'S7' END AS version I do not always want to repeat the edition = 'xxx' condition, such as CASE WHEN edition = 'STAN' AND has9 = 1 THEN '9' ELSE WHEN has8 = 1 THEN '8

Multiple 'or' condition in Python [duplicate]

我只是一个虾纸丫 提交于 2019-12-18 12:18:45
问题 This question already has answers here : How to test multiple variables against a value? (24 answers) Closed 5 years ago . I have a little code issue and it works with IDLE and not with Eclipse, can I write this : if fields[9] != ('A' or 'D' or 'E' or 'N' or 'R'): instead of this : if fields[9] != 'A' and fields[9] != 'D' and fields[9] != 'E' and fields[9] != 'N' and fields[9] != 'R': Thank you. 回答1: Use not in and a sequence: if fields[9] not in ('A', 'D', 'E', 'N', 'R'): which tests against

XPATH Multiple Element Filters

筅森魡賤 提交于 2019-12-17 17:37:00
问题 I have the following sample XML structure: <SavingAccounts> <SavingAccount> <ServiceOnline>yes</ServiceOnline> <ServiceViaPhone>no</ServiceViaPhone> </SavingAccount> <SavingAccount> <ServiceOnline>no</ServiceOnline> <ServiceViaPhone>yes</ServiceViaPhone> </SavingAccount> </SavingAccounts> What I need to do is filter the 'SavingAccount' nodes using XPATH where the value of 'ServiceOnline' is 'yes' or the value of 'ServiceViaPhone' is yes. The XPATH should return me two rows!! I can filter

LINQ Joining in C# with multiple conditions

最后都变了- 提交于 2019-12-17 15:23:04
问题 I have a LINQ Joining statement in C# with multiple conditions. var possibleSegments = from epl in eventPotentialLegs join sd in segmentDurations on new { epl.ITARequestID, epl.ITASliceNumber, epl.DepartAirportAfter, epl.AirportId_Origin, epl.AirportId_Destination } equals new { sd.ITARequestId, sd.SliceIndex, sd.OriginAirport, sd.DestinationAirport } where epl.DepartAirportAfter > sd.UTCDepartureTime and epl.ArriveAirportBy > sd.UTCArrivalTime select new PossibleSegments{ ArrivalTime = sd

Sum over rows with multiple changing conditions R data.table

半城伤御伤魂 提交于 2019-12-12 04:05:17
问题 I am trying to create a column in a data.frame or data.table with two conditions. The difference to the posts I have seen and which I have tried to modify below is that I do not have 'value' for the conditions but the conditions depend on other variables in the data.frame . Let's assume this is my data frame: mydf <- data.frame (Year = c(2000, 2001, 2002, 2004, 2005, 2007, 2000, 2001, 2002, 2003, 2003, 2004, 2005, 2006, 2006, 2007), Name = c("Tom", "Tom", "Tom", "Fred", "Gill", "Fred", "Gill"

How to populate a column with Yes or No based on the variance values of another column

亡梦爱人 提交于 2019-12-11 19:37:56
问题 I am trying to populate Yes or No in the column Move, based on a range of values in the column 'Variance' that is attributable to 3 products in the same month for the same customer. In the picture titled "Expected Example Result", the Variance column for Customer1 and in Month 3, you can see that Customer1 spent $22.24 less on product1, $655.53 less on product2 and spent $319.28 more on product3 meaning they moved money away from product1 and 2 and put into 3. The problem is I am mainly