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-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python