1) Why do we use loops in programming? a) To increase the accuracy of code b) To repeat a specific block of code c) To make debugging harder d) To increase the time taken to complete 2) When will a "while loop" end? a) When the time of repetition ended b) When the number of repetition reached c) When the condition is true d) When the condition is no longer true 3) while (num < 10): means that... a) the range is 0-10 if 1st number is 0 b) the first number is negative number c) loop repeats if num >= 10 d) loop repeats until num >= 10 4) 0,2,4,6,8. How can we produce this sequence? a) while (num > 8) : b) num +=2 c) num = -2 d) print("num") 5) What is an infinite loop ? a) It does not cause an error in code block b) There will be 1 value produced c) A never-ending loop d) It will not crash the program 6) We use "for" loop if ... a) we know when it will end b) we don't know when it will end c) we don't have the last value d) we have the first value 7) How can a "for" loop end? a) When the final value is not reached b) When the situation is no longer valid c) When the situation is met d) When the time set is reached 8) In Python, a list is used to ... a) transfer values to another variable b) store multiple values in a single variable c) assign one value in many different variables d) generate random values to a single variable 9) Choose the correct syntax for list. a) myList = ["lemon" , 100, 76, "apple"] b) List1 = (lemon, 10, 45, papaya) c) list1 == [lemon, 100, 76, apple] d) list2 = {"lemon", 10, 45, "apple"] 10) range(10) means... a) there will be 11 numbers in the output b) the first output is 1 c) 0-9 will be the output d) the number is arranged in descending order 11) range(15,25) means... a) 20 is not a correct output b) 15-25 will be the output c) the first output value is 16 d) 25 is not included in output 12) Which one shows output data with the increment by 3? a) range (2, 3) b) range (0, 3, 1) c) range (3, 100, 2) d) range (50, 70, 3) 13) If a while loop is used, we can display the data in descending order by using... a) timeInt > 0 b) timeInt += 1 c) timeInt -= 1 d) timeInt < 0 14) Which one is not used in countdown timer ? a) for loop b) variables c) user input d) Python's in-built time module 15) timeDiff = "currentTime" - "lastTime". Find an error in this code. a) No capital letter can be used b) The quotation marks should be removed c) Double equal sign (==) should be used d) The minus sign (-) should change to plus sign (+)
0%
Coding Quiz (9) : Python Loops
Chia sẻ
Chia sẻ
Chia sẻ
bởi
Guanjie0807
Chỉnh sửa nội dung
In
Nhúng
Nhiều hơn
Tập
Bảng xếp hạng
Hiển thị thêm
Ẩn bớt
Bảng xếp hạng này hiện đang ở chế độ riêng tư. Nhấp
Chia sẻ
để công khai bảng xếp hạng này.
Chủ sở hữu tài nguyên đã vô hiệu hóa bảng xếp hạng này.
Bảng xếp hạng này bị vô hiệu hóa vì các lựa chọn của bạn khác với của chủ sở hữu tài nguyên.
Đưa các lựa chọn trở về trạng thái ban đầu
Chương trình đố vui
là một mẫu kết thúc mở. Mẫu này không tạo điểm số cho bảng xếp hạng.
Yêu cầu đăng nhập
Phong cách trực quan
Phông chữ
Yêu cầu đăng ký
Tùy chọn
Chuyển đổi mẫu
Hiển thị tất cả
Nhiều định dạng khác sẽ xuất hiện khi bạn phát hoạt động.
Mở kết quả
Sao chép liên kết
Mã QR
Xóa
Bạn có muốn khôi phục tự động lưu:
không?