标签:confirm linu conf NPU ase bin password 乘法 you
断断续续和反复了几次,今天开始老实的写笔记和画流程图:
一、python格式:
#!/usr/bin/env python # -*- coding: utf-8 -*-
二、基本的输入框和打印:
#!/usr/bin/env python # -*- coding: utf-8 -*- print("Hello world!") name = input("Name:") age = input("Age:") job = input("Job") info1 = """ ==================== info1 of %s ================== name:%s age:%s job:%s """ % (name,name,age,job) info2 = """ ==================== info2 of {Name} ================== name:{Name} age:{Age} job:{Job} """.format(Name=name,Age=age,Job=job) info3 = """ ==================== info3 of {0} ================== name:{0} age:{1} job:{2} """.format(name,age,job) print(info1,info2,info3)
三、if判断语句:
#!/usr/bin/env python # -*- coding: utf-8 -*- import getpass #只能在Linux下使用 name = "jack" passwd = "jack123" user = input("Please input your name:") #password = input("Please input your passwd:") password = getpass.getpass("Please input your passwd:") if user == name and passwd == password: print("Welcome %s" % user) else: print("get out")
四、while循环:
#!/usr/bin/env python # -*- coding: utf-8 -*- # count = 0 # # while count <3: # num = int(input("Please input num:")) # if num == 22: # print("your are rigth") # break # elif num > 22: # print("bigger") # else: # print("smaller") # count = count + 1 # else: # print("You have tried too many times..") count = 0 while count <3 : num = int(input("Please input num:")) if num == 22: print("your are rigth") break1 elif num > 22: print("bigger") else: print("smaller") count = count + 1 if count ==3: confirm = input("Do you want to continue...") if confirm != "n": count = 0
五、for循环
#!/usr/bin/env python # -*- coding: utf-8 -*- #for循环 for i in range(10): print(i) #for循环,打印奇数 for i in range(1,10,2): #三个参数:[开始、结束)步长 print(i) #for循环,打印偶数 for i in range(0,10,2): print(i) #九九乘法表 for i in range(1,10): for j in range(1,10): if j <= i: print(j,"*",i,"=",i*j)
标签:confirm linu conf NPU ase bin password 乘法 you
原文地址:https://www.cnblogs.com/zheng-weimin/p/9016772.html