代码:
'''
用户与程序交互:
    input( )输入
    print()输出
username=input('请输入提示信息')
'''
username=input('请输入用户名:')
print(username)
password = input('请输入密码:')
print(password)


# 如果
# username == 'tank ' True
# and: 左右两边的条件都为了True才为True,否则为False
# password == '123' True
# if 条件判断:如果条件判断 == True,执行if下的代码
if  username =='tank' and password == '123':
      # False and True   ---》 False
      print('登录成功')
else:
      print('登陆失败')

# 占位符: %s
str1 = '很帅'
print('tank%s' % (str1,))  #  tank很帅

str2 = '信念与我同在,我将无坚不摧'

print('自信养成记1: %s' % (str2, ))


price1 = input('请输入该用户当月扣费月租')
all = input('请输入该用户当前余额: ')

print('亲爱的移动用户,您当前月租为[%s]元,账户余额为[%s]元 '
      % (price1,all))


# - 算数运算符
print(1+1) # 2
n1 = 1
# n1 =n1 + 1  # n1 += 1
# print(n1)  # 2
n1 += 1

# 赋值运算符: -=
print(10 - 1)  # 9

# *=
print(12 * 12)  # 144
print(11 / 3)  # 3.666...
print(11 // 3)  # 3
print(11 % 3)  # 2

# 比较运算符
print(1 == 2)  # False
print(1 >2)  # False
print(1 < 2)  # True
print(1 >=2 )  # False
print(1 <= 2)  # Ture

# is:比较两个变量的id是否相等
x = 10
print(id(x) == id(x) )  # True

print(x is x)  # True

#逻辑运算符
# and: 左右两边的条件都为了True才为True,否则为False
print(x == 1 and x == 10)  # False
print(x == 10 and x == 10) # True

# or:判断两边的条件是否成立,其1成立则为Ture
print(x == 10 or x == 1)  #  True

# not:取反
print(x == 10)  # True
print(not x == 10)   # False

# no-->and-->or
#            True or Fslse
print(not x == 1 or x == 10 and x == 20)  # True

# 链式赋值
n = 10
y = n
z = y
print(n,y,z)

n = y = z = 10
print(n,y,z)


#交叉赋值
x = 10
y = 20
# x与y的值互换
# x = 20    y = 10
z = x   # 10
x = y   # 20
y = z   # 10

x = 10
y = 20
# 10, 20 = y = 10, x=20
x, y = y, x
print(x,y)   # 20  10


# 解压缩赋值
#           0   1   2
list1 = [1,2,3]
x = list1[0]
y = list1[1]
z = list1[2]
print(x,y,z)  #  1  2  3
x,y,z = list1
print(x,y,z)  #  1  2  3

#猜测游戏: 猜测用户输入的字符是否是9527
number=9527
guess=('请输入猜测数字')
print(guess)
print(type(guess))  # str
#把字符串类型转为整型
guess=int(guess)
print(type(guess))  # int
if guess==number:
     print('猜对了!')
elif guess<number:
      print('猜小了!')
else:
     print('猜大了!')

'''
while循环:
     语法:
        while 判断条件:
             # 若条件成立则"循环"执行以下代码
             print('111')
        break:结束本层循环
'''
import time
while True:
     print(11111)
     time.sleep(1)
     break

# 猜字符游戏:猜测用户输入的字符是否是9527,限制只能猜3次
number = 9527
init = 1  # 1 2 3 4
while True:
    # 若int大于3结束循环
    if init >  3:
       print('猜错3次了,gun吧!')
       break

       guess= input('请输入猜测数字:')
       guess = int(guess)

    if guess == number:
        print('猜对了!')
        break

    elif guess < number:
        print('猜小了!')


    else:
        print('猜大了!')

     # 若没有退出循环证明猜错了,init + 1

init += 1

list1 = [1,2,3,4,5]
# list1_len = len(list1)  # 5
#
#white list1_len > 0:
#      list1_len -= 1
#      # print(list1_len)  # 4 3 2 1 0
#      print(list1{list1_len})

# 依次循坏取出list1中的每一个值
for x in list1:
    print(x)
笔记:
1.可变与不可变
当数据修改时,id不变称之为可变类型,否则称之为不可变类型。

2. - 流程控制
    对流程的控制,控制某些事情的发生

       -if分支判断:
          语法:
               if判断条件:
                 #条件若成立执行
                  print('条件成立')

                 #若if条件成立,则执行此处
                 elif判断条件:
                     print(另一个条件成立)
                 #若if与elif条件不成立,则执行此处
                 else# 若条件不成立则执行
                     print"条件不成立")