Day7_100days of code in python
2021/10/24 1:10:05
本文主要是介绍Day7_100days of code in python,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Indentation:
def my_function(): print("Hello")
Spaces vs. Tabs
PEP 8 -- Style Guide for Python Code | Python.orghttps://www.python.org/dev/peps/pep-0008/
While loops
What about the for loop:
for item in list_of_items: #Do something to each item
for number in range(a,b): print(number)
While
while something_is_true #Do something repeatedly
while +condintion:
Infinite loop
if you don't know why it is an infinite loop, just print the condition.
def turn_right(): turn_left() turn_left() turn_left() def jump(): turn_left() while front_is_clear() and wall_on_right(): move() turn_right() move() turn_right() move() while front_is_clear() and wall_on_right(): move() turn_left() while not at_goal(): if front_is_clear(): move() elif wall_in_front(): jump()
成功啦!!!
这篇关于Day7_100days of code in python的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-26Python基础编程
- 2024-11-25Python编程基础:变量与类型
- 2024-11-25Python编程基础与实践
- 2024-11-24Python编程基础详解
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南