Yahoo Αναζήτηση Διαδυκτίου

Αποτελέσματα Αναζήτησης

  1. @inspectorG4dget: On modern Python 3's CPython reference interpreter, the set will perform better, but prior to 3.2, it would have performed worse (because it rebuilt the set prior to each test). It was only optimized to make such tests against a set literal of constant literals build a frozenset at compile time and reuse it in 3.2 .

  2. 25 Απρ 2016 · password is not an input equal to string "your password", which makes the while expression True, while true repeat. if password does equal 'your password' expression is false, exit loop. While password equals anything except 'your password', expression is True, repeat loop till False. If loop becomes False, print end of line, 'Thank you', end ...

  3. 30 Ιαν 2013 · Don't use while True and break statements. It's bad programming. Imagine you come to debug someone else's code and you see a while True on line 1 and then have to trawl your way through another 200 lines of code with 15 break statements in it, having to read umpteen lines of code for each one to work out what actually causes it to get to the break.

  4. 27 Δεκ 2022 · First of all there are differences between the for loop in python and in other languages. While in python it iterates over a list of values (eg: for value in [4,3,2,7]), in most other languages (C/C++, Java, PHP etc) it acts as a while loop, but easier to read.

  5. 14 Δεκ 2020 · The best explanation for while not guessed is that it is essentially saying "while guessed is not equal to true". This is to say it is basically "while guessed is false." So the while loop will run for as long as guessed is false and tries > 0. However, if guess is every made to be true, then the while loop will stop running.

  6. S. Lott: I'm pretty sure his question was about how to implement do while in python. So, I wouldn't expect his code to be completely correct. Also, he is very close to a do while... he is checking a condition at the end of the "forever" loop to see if he should break out. It's not "do-forever". –

  7. 1 Νοε 2012 · I am reading serial data and writing to a csv file using a while loop. I want the user to be able to kill the while loop once they feel they have collected enough data. while True: #do a bunch of serial stuff #if the user presses the 'esc' or 'return' key: break

  8. 4 Φεβ 2023 · while expression: if expression: print "something" does not because both the while and if statements are compound. For your specific example, you can replace the if expression: assignment part with a conditional expression , so by using an expression instead of a complex statement:

  9. 24 Οκτ 2008 · In this case on the first call, next() executes up to the yield statement and yield 'n', on the next call it will execute the increment statement, jump back to the 'while', evaluate it, and if true, it will stop and yield 'n' again, it will continue that way until the while condition returns false and the generator jumps to the end of the function.

  10. 26 Μαΐ 2012 · #heres a simple algorithm to find the greatest common denominator: iterations = 0; #used to calculate number of times while loop is executed u = 54; v= 42; d = v-1; #u is the numerator, v is the denominator, d is the number decremented by one while ((v % d !=0) & (u % d != 0)): #while both numerator AND denominator cannot be evenly divided by ...

  1. Γίνεται επίσης αναζήτηση για