zoukankan      html  css  js  c++  java
  • python練習

    #登录,账户密码储存在文件中,限制登录
    
    count = 0
    
    for i in range(3):
        b = input("账号:")
        c = b + "," + input("密码:")+"
    "
    
        passwd_f = open('D:pythonpassword_f.txt', 'r')
        text = passwd_f.readlines()
        for j in range(len(text)):
            if text[j] == b + "
    ":
                print("----账号已经被锁定----")
                exit()
    
        passwd = open('D:pythonpassword.txt', 'r')
        text = passwd.readlines()
        for h in range(len(text)):
            if text[h] == c:
                print("------欢迎你------")
                exit()
    
        print("--密码或账户错误--")
        passwd.close()
    else:
        print("--账户已经被锁定--")
        passwd_f = open('D:pythonpassword_f.txt', 'a')
        passwd_f.write(b + "
    ")
        passwd_f.close()
    #username = input("账号:")
    #password = input("密码:")
    

    打印九九乘法表

    1*1=1
    2*1=2 2*2=4
    3*1=3 3*2=6 3*3=9
    4*1=4 4*2=8 4*3=12 4*4=16
    5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
    6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
    7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
    8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
    9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

    num_h=1
    while num_h<=9:#循環h行  
        temp=1
        while temp<=num_h:   #循環l列
            print(str(num_h) + "*" + str(temp)+"="+ str(num_h*temp),end=" ")#打印不換行
            temp =temp+1
            
        print()  #換行
        num_h+=1

    ***************************************************************************************************

    隨機輸入成績判斷等級

    score =int(input("score:"))


    if score>90:
        print("A")
    elif score>80:
        print("B")
    elif score>70:
        print("c")
    else:
        print("D")

    *************************************************************************************************

    打印星星
    ****
    ****
    ****
    ****
    h=int(input("chang:"))#輸入高度

    l=int(input("kuan:"))#輸入寬度

    num_h=1


    while num_h<=l:#循環h行
        num_l=1
        while num_l<=h:   #循環l列
            print("*",end="")#打印不換行
            num_l+=1
        print()  #換行
        num_h+=1

    ************************************************************************************



    打印星星
    *
    **
    ***
    ****

    h=int(input("chang:"))#輸入高度
    num_h=1
    while num_h<=h:#循環h行  
        temp=num_h
        while temp>0:   #循環l列
            print("*",end="")#打印不換行
            temp =temp-1
        print()  #換行
        num_h+=1

    **********************************************************************************************

    比大小

    a=input("a:")
    b=input("b:")
    c=input("c:")
    sum=""


    if a>b:
        sum=a
        if sum>c:
            print("max is",a)
        else:
            print("max is ",c)
    else:
        sum=b
        if sum>c:
            print("max is",b)
        else:
            print("max is ",c)

    **************************************************************************************

    猜年龄

    age_of_princal=56

    while True:
        guess_age=int(input(">>:"))
        if guess_age==age_of_princal:
            print("yes,you got it")
            break      #跳出程序
        elif guess_age>age_of_princal:
            print("should try smaller....")
        else:
            print("try bigger....")
    print("end")

    *************************************************************************************************************

    无论你选择做什么,追求完美的程度决定你成就的高度。
  • 相关阅读:
    取代iframe,实现页面中引入别的页面
    axios请求
    接口跨域
    es7,es8
    promise
    移动端开发调试工具神器--Weinre使用方法
    资本论第一卷笔记
    2018春季实习生校招面经(一)阿里篇
    linux小实验-考勤模拟程序
    在基于debian的deepin或者Ubuntu上双等号“==”和双中括号“[[]]”不能使用的真相
  • 原文地址:https://www.cnblogs.com/chiyhua/p/12201228.html
Copyright © 2011-2022 走看看