python-1

#!-*- coding:utf-8 -*-
 
''':多行注释
 
type():查看数据类型
int integer :整数,把字符串转成int,用int(被转的数据)
str string :字符串,把数据转成字符串用str(被转的数据)
 
\n 换行
 
\t 制表符
 
input接收的所有数据都是字符串,即便你输入的是数字,但依然会被当成字符串来处理
 
 
 
age_of_princal = 56            #校长年龄
guess_age = int(input(">>:"))     #赋值
if guess_age == age_of_princal :      #如果等于56,YES
    print("YES,you got it..")
else:
    print("No,it'seek wrong.")             #如果不等于56,NO
 
 
IndentationError: expected an indented block:缩进错误
 
True     真 正确的
False    假 错误的
break   终止
continue   跳出本次循环
 
whihe
+         当正常结束后 去执行
else
 
and  且,并且
只有两个条件全部为True(正确)的时候, 结果才会为True(正确)
 
 
num += 1  等价于 num = num + 1
num -= 1  等价于 num = num - 1
num *= 2  等价于 num = num * 2
num /= 2  等价于 num = num / 2
num //= 2  等价于 num = num // 2
num %= 2  等价于 num = num % 2
num **= 2  等价于 num = num ** 2
 
while 循环
 
 
九九乘法表
 
firet = 1
 
while firet<=9:
    sec = 1
    while sec <= firet:
        print( str(sec)+"*"+str(firet)+ "=" +str(sec * firet),end="\t")
        sec += 1
    print()
    firet += 1
 
posted @ 2018-01-18 16:22  阿狸灬控丶  阅读(96)  评论(0)    收藏  举报