Portal.scitech.au.edu



Worksheet 3??????????????? loop (????????????????) ?? Python ???? ????????????????????????? ????????????????????????????? 100 ??? ??????????????????????????????????????????????????? 100 ????? ?????????????? ???????????????????????????? ????print(‘My name is Donald Duck.’)print(‘My name is Donald Duck.’) :print(‘My name is Donald Duck.’)????????????????? 10000 ?????? ????????????????????? ???????????????????????????????????????????????? ? ?????????????????? ??????????????????????????? ?????????????????????? ? ?????????????????????????????? ????????????????? Loop ????????????????????? ??????????????????? ??? ????? ????? ????? 5 ????? ????????? for-loop ??????????????????????? print( ) ????????? 5 ????? ?????????????????????????? 1,000 ????? ??????????????? print( ) ????????? 1,000 ????? *****???????? range(0, 5) ????????????????? range(5)???????????????????????????????????????? ??????????? 0 ???????????????????? code ?????????????????????????????????? 1 ??????????????????? 15 ????? ??????????????????????? list ????????????????????????? ???????? list ?????????????????????????? for-loop ?????????????????????????????????????????????????????? Python code ?????????? ?? code ??? ???????????? for i in list_x: Python ???????????????????????? i ?????????????????????????? list_x ??????????????????????????????????????? list_x?????????????? for i in range(len(list_x)): ?????????????????????????? ?????????????????????????????? i ?????????? len(list_x) ???????????????????????? list_x ??????????? 9 ??????? for i in range(len(list_x)): ????????????????????????? for i in range(9): ???????????? i ????????????? 0 ??? 9 ????????????????? list ???????????????????????? i ???? index ??????????????? print( ) ???????????? list_x[i] ????????????????? list_x????????????????? ????????????????????????????? for loop ?????????????????? 0 ??????????????????? ??????????????????? * ????????? ??????????????????????????????? list_x ???????????????????????????? 2 4 6 0 * 12 * 0 8???????? ????????????????????????????????????????????????????????? ???????????????????? % ????10 % 2 == 0 ??????????????????? True (????????????????? == ?????????????????????????????????)????????????????? ????????????????????????????? for loop ?????????????????????????????????????? ???? -9 ???? 9 ????????????????????????? ?????????????????? 10 ?????? list ??????????????? string ?? list ????? ?????? loop ?????? m ?????????????? Avengers ?????????????? m[0] ????????????????????????????? ???? m[0] ??? Avengers ?????????????? A ???? if m[0] == “A”: ????????????????????? m[0] ????????????????? A ??????? ?????????????????????????????????????????? ????if m[0] == “A”: # ??? m[0] ???????? A ???????????? 1 ??? 2 ??????????????????? 3 ?????? 1 ?????? 2else: ?????? 3????????????????? ?????????????????? Python code ??????????????????????????????????????????????????? S ??? T?????????????????? Python code ?????????????????????????????????????????????????? 8 ?????????????????????????????? loop ??????????????????????????????????????????? ?????????????????? break ??? ????????????? loop ??????????????????? i ???????????? 5 ??????????? ????? if i < 5: ??????????????????????? i ???????? 5 ?????? i ??????? 5 ?????????????? else ???????? break loop?????????????????? Python code ?????????????????? list ???????????????????????????????????????????? 4 ????????????? Python code ??????????????????????????? (??????????) ???????????????? my_int ????????????????????? my_int ???????????? 1 ??????????????????????? + ???????????????????????? - ???? ???????????? 6 Python code ????????? + - + - + - ??? 6 5 4 3 2 1 ??????? Python code ??????????????????????????? 2 ????????? a ??? b ?????????????????????????????????? a ??? b (?????? a ??? b ????) ????????????????????????? * ????????????????????????? 2 ???? a = 1 ??? b = 14 ?????????????????? 1 * 3 4 5 6 7 8 9 10 11 * 13 14??????? Python code ???????????????????? 0 ??? 100 ????????????????????????????? 5 ????? ???????????????????????????? 31 – 49 ??? 61 – 79??? Python code ????????20429001484983Loop i00Loop i172910585080200740955188713200612743152944Loop j00Loop jLoop i ???? loop ?????????????????????????????? (row) ??? loop j ???? loop ????????????????????? column ?????? loop i ????? loop (??????? outer loop) ??????????? loop j (inner loop) ??????? ???? ??????????? outer loop ?????? i ??????? 1 (??? range(1, 11)) ??????????????????? loop j ?????? j ????????????????? 1 ??? 10 (????? 10 ????? 11 - 1) ??????? loop j ????? print() ??????????????????? ???????? loop i ?????? i ???????????? 2 ?????????? loop j ????? ?????????????????? ? ???? loop i ??????????????????????????????????? ??????????????????????????????????? ??????????????????????????? if j < i + 1 ??????????? i ??????????? Python code ?????????? code ????????????????????????????????????????????????? ???????????????????????????? –-??????????????????????????????????????????? x % 2 == 0 ????????????? x ?????????? ???????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????? floor division (//) ????35 // 10 -- > ????? 3 ?????????????????? % 2 ????????????????????????????????? ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download