python基础知识day02
2018-01-18 10:09
239 查看
7、分支语句:if elif elif ... else
age = input("请输入年龄")
if age >= 18:
print("成年人")
elif age < 0:
print("婴儿")
else:
print("青少年")
8、逻辑运算符:and or not 表示 与 或 非
9、循环语句
count = 0
while count < 5:
print("count: %d" % count)
count += 1
10 、 字符串输出格式:
%d表示整型输出 %06d 表示输出的数字有六位,不足写0
%s 表示字符串输出
%f 表示浮点型输出,%02f表示小数点后保留两位数
输出的字符中如果有要被替换的字符或数字,用%替换。如:print("price is %02f ,money is %d" % (price,money))
11、转义字符:\+ \- \* \\ \** \t \n 等
12、嵌套循环:
row= 1
while row<= 9:
col = 1
while col <= row:
print("%d * %d = " % (col, row),end="\t")
col += 1
print("")
row += 1
age = input("请输入年龄")
if age >= 18:
print("成年人")
elif age < 0:
print("婴儿")
else:
print("青少年")
8、逻辑运算符:and or not 表示 与 或 非
9、循环语句
count = 0
while count < 5:
print("count: %d" % count)
count += 1
10 、 字符串输出格式:
%d表示整型输出 %06d 表示输出的数字有六位,不足写0
%s 表示字符串输出
%f 表示浮点型输出,%02f表示小数点后保留两位数
输出的字符中如果有要被替换的字符或数字,用%替换。如:print("price is %02f ,money is %d" % (price,money))
11、转义字符:\+ \- \* \\ \** \t \n 等
12、嵌套循环:
row= 1
while row<= 9:
col = 1
while col <= row:
print("%d * %d = " % (col, row),end="\t")
col += 1
print("")
row += 1
相关文章推荐
- Python基础知识---字典
- python初入门:与其他语言略有区别的一些基础知识1
- Python学习基础知识概要
- python基础教程-第1章节 基础知识
- Python 爬虫(1)基础知识和简单爬虫
- Python基础知识Notes
- Python 基础知识教程
- Python 第一章 基础知识(4) 变量和语句
- Python基础语法(Python基础知识点)
- python微教程---第一季(第二集)----基础知识(让python运行起来)
- python基础知识了解
- python基础知识
- Python 的一些基础知识
- Python3 网络编程1--基础知识了解
- python基础知识之元组
- python---基础知识
- [leetcode]Merge k Sorted Lists @ Python [基础知识: heap]
- 01月23日【Python3 基础知识】
- Python 基础知识学习手记
- Python基础知识学习重点内容