038 while loop tủ tài liệu training

2 23 0
038 while loop tủ tài liệu training

Đang tải... (xem toàn văn)

Thông tin tài liệu

while loop While loops, like the For loops, are used for repeating specific block of codes The "while" loop is capable of anything that the "for" loop can But unlike a for loop, the while loop will not run n times, but until a defined condition is no longer met If the condition is initially false, the loop body will not be executed at all The syntax of this loop is: while (condition): statement_1 statement_2 statement_n Let's make our examples; In [1]: count = while (count < 10): print ('The count is:',count) count += print("It's done!") The count is: The count is: The count is: The count is: The count is: The count is: The count is: The count is: The count is: The count is: It's done! In [2]: a = while (a < 10): print (a) a+= The Complete Python Programming Course: (Beginner to Advanced) In [3]: n = 10 sum = i = while i

Ngày đăng: 17/11/2019, 07:33

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan