• python基础语法


    # 流程控制之if...else

    #(1)
    
    # age_of_girl = 31
    # if age_of_girl > 30:
    	# print("阿姨好")

    # (2)
    
    # age_of_girl =18
    # if age_of_girl >30:
    	# print('阿姨好')
    # else:
    	# print("小姐姐好")

    #(3)
    # age_of_girl = 18
    # height =171
    # weight =88
    # is_pretty =True
    # success = False
    
    # if age_of_girl >= 18 and age_of_girl < 22 and height > 170 and weight < 100 and is_pretty == True:
    	# if success:
    		# print("表白成功,在一起")
    	# else:
    		# print("什么爱不爱情的,关我什么事情呢?")
    
    # else:
    	# print("阿姨好")

    # (4)
    
    # text = input(">>:请输入成绩分数")
    # text =int(text)
    
    # if text >= 90:
    	# print("优秀")
    # elif text >= 80:
    	# print("良好")
    
    # elif text >= 70:
    	# print("普通")
    # else:
    	# print("很差")

    # ### 验证密码错误类型

    # name = input("请输入用户名")
    # passwrod = input("请输入密码")
    
    # if name =="黄将用" and passwrod == "123456":
    	# print("登录成功")
    
    # else:
    	# print("您输入的密码或者账号有误,请从新输入")

    # while True:
    	# name =input("请输入名字")
    
    	# if name == "var1":
    			# print("超级管理")
    	# elif name == "var2":
    			# print("会员管理")
    	# elif name == "var3" or name == "var4":
    			# print("业务主管")
    	# else:
    		# print("普通用户")

    # agevar = 48
    # age_var =int(input(">>请输入:"))
    # if age_var > agevar:
    	# print("你说的年龄有点大了")
    # elif age_var <agevar:
    	# print("你说的年龄小了,我滴哥")
    # else:
    	# print("没有错,这年龄就是哥``哈哈")

    ## ### while 循环语句

    #打印0-10
    
    coent = 0
    while coent <= 10:
    	print(coent)
    	coent+=1

    #打印0-10 之间的偶数


    coent = 0 while coent <= 10: if coent%2 == 0: print(coent) coent+=1

    #打印0-10 之间奇数


    coent = 0 while coent <=10: if coent%2 ==1: print(coent) coent+=1

    #死循环


    # import time # num = 0 # while True: # print(num) # time.sleep(1) # num+1

    #练习,要求如下:

    # 1.循环验证用户输入发用户名与密码
    # 2认证通过后,运行用户重复执行命令
    # 3当用户输入命令exit时,则退出整个程序
    
    # (1)
    # name = "var1"
    # passwrod = "12345"
    # while True:
    	# inp_name = input("用户名>>>:")
    	# inp_pwd = input("密码>>>>:")
    	# if inp_name == name and inp_pwd == passwrod:
    		# print("登录成功-->准备走下面")
    		# while True:
    			# cmd = input(">>>>:")
    			# if not cmd:continue
    			# if cmd =="exit":
    				# break
    			# print("run <%s>"%cmd)
    	# else:
    		# print("用户名或密码错误")
    		# continue
    	# break

    # (2)
    
    name = "mengtongxue"
    password = "0521"
    tag =True
    while tag:
    	inp_name=input("请输入姓名>>>:")
    	inp_pwd =input("请输入纪念日>>:")
    	if inp_name ==name and inp_pwd == password:
    		print("你与老婆的纪念日是:5月21日,庆祝吧!")
    		while tag:
    			cmd = input(">>>>")
    		if not cmd:continue
    		if cmd == "exit":
    			tag = False
    			continue
    		print("run<%s>"%cmd)
    	else:
    		print("哟嚯,需要在确定一下是哪天哟")
    

      

  • 相关阅读:
    iPerf 笔记
    Monkey相关参数 笔记
    adb相关指令 笔记
    Linux常用命令 笔记
    eclipse配置android开发环境并搭建第一个helloWord工程
    python + eclipse + pydev 安装、配置
    print带参数格式
    JS获取按下的键盘字符
    Mysql 创建用户并对其赋予操作权限
    扩展内置对象
  • 原文地址:https://www.cnblogs.com/huangjiangyong/p/10779324.html
Copyright © 2020-2023  润新知