cp2025 計算機程式

  • Home
    • SMap
    • reveal
    • blog
  • About
    • cs101
    • Computer
      • llama
      • nginx
    • AI
      • QandA
      • Teams
    • Homework
  • Topics
    • Git
      • Git_ex1
      • Git_ex2
    • Python
      • SE
      • CL
      • Loops
      • Recursion
      • SA
      • SST
      • Maze
      • Collect
      • GT
      • Python_ex1
    • Javascript
      • HTML and CSS
    • Project
      • Waitress
      • API
  • Brython
    • Brython_ex
    • Robot_ex
  • Ref
    • Reeborg
      • ex1
      • Otto_ninja
    • tkinter
    • Pyodide
    • Pyodide_ex
    • Pyodide2
      • robot.py
      • Example2
    • Pyodide3
      • png_files
      • Harvest
SE << Previous Next >> Loops

CL

條件判斷(Conditional Logic)

根據環境狀況做出不同的動作。

# 範例 1:如果前方有牆就左轉
if wall_in_front():
    turn_left()

# 範例 2:如果有物品就撿起來
if object_here():
    take()

# 範例 3:如果前方沒牆就前進,否則左轉
if not wall_in_front():
    move()
else:
    turn_left()


SE << Previous Next >> Loops

Copyright © All rights reserved | This template is made with by Colorlib