Python、C、C++ 和 Java 编程基础与实践
Python 编程基础
Python 是一种功能强大的编程语言,除了常见的数据结构,它还有其他值得探索的数据结构,例如集合(sets)。集合对象拥有一些方法,可用于查找同时出现在两个集合中的元素,或者仅出现在特定集合中的元素。
在流程控制方面,Python 支持多种传统的流程控制语句:
- if 语句 :用于根据条件执行不同的代码块。例如:
age = 15
if age >= 16:
print "you are old enough to drive"
elif age == 15:
print "you are old enough for a permit"
else:
print "sorry, you can't drive yet"
- while 循环 :会先进行条件检查,如果条件为真,则执行代码块。执行完代码块后,会再次进行条件检查。示例如下:
#!/bin/python
age = int(raw_input('Please enter your age: '))
while (age < 0):
print "You can't be that young!";
age = int(raw_input('Please enter your age: '))
prin
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



