• Python-100天代码


    import turtle
    
    
    turtle.pensize(4)
    turtle.pencolor('red')
    turtle.forward(100)
    turtle.right(90)
    turtle.forward(100)
    turtle.right(90)
    turtle.forward(100)
    turtle.right(90)
    turtle.forward(100)
    turtle.mainloop()
    绘制正方形
    f = float(input('输入华氏度温度:'))
    c = (f - 32) / 1.8
    print('%.1f华氏度 = %.1f摄氏度' % (f, c))
    华氏度转摄氏度
    import math
    
    
    radius = float(input('输入圆的半径:')
    perimeter = 2 * math.pi * radius
    area = math.pi * radius * radius
    print('周长:%.2f' % perimeter)
    print('面积:%.2f' % area)
    计算圆的周长和面积
    year = int(input('输入年份'))
    is_leap = year % 4 == 0 and year % 100 != 0 or year % 400 == 0
    print(is_leap)
    判断闰年
    username = input('输入用户名')
    password = input('输入口令')
    # 如果希望输入口令时,没有回显,可使用getpass模块的getpass函数
    # import getpass
    # password = getpass.getpass('输入口令')
    if nameuser == 'admin' and password == '12345':
        print('身份验证成功!')
    else:
        print('身份验证失败!')
    用户身份验证
    """
    f(x) = 3 * x - 5 (x > 1)
    f(x) = x + 2 (-1 < x <= 1)
    f(x) = 5 * x + 3 (x <-1) 
    """
    
    x = float(input('x = '))
    if x > 1:
        y = 3 * x - 5
    else:
        if x > -1:
            y = x + 2
        else:
            y = 5 * x + 3
    print('f(%.2f) = %.2f' % (x, y))
    分段函数求值
    value = float(input('输入长度:'))
    unit = input('输入单位:')
    if unit == 'in' or unit == '英寸':
        print('%f 英寸 = %f 厘米' % (value, value * 2.54))
    elif unit == 'cm' or unit == '厘米':
        print('%f 厘米 = %f 英寸' % (value, value / 2.54))
    else:
        print('输入有效单位!')
    英寸与厘米单位转换
    from random import randint
    
    
    face = randint(1, 6)
    if face == 1:
        result = '唱歌'
    elif face == 2:
        result = '跳舞'
    elif face == 3:
        result = '学狗叫'
    elif face == 4:
        result = '俯卧撑'
    elif face == 5:
        result = '绕口令'
    else:
        result = '讲笑话'
    print(result)
    掷骰子游戏
  • 相关阅读:
    EVM靶机渗透
    Joomla漏洞复现
    渗透测试
    Kali软件库认识
    谷歌hack语法
    Metasploit学习
    sqli-labs less-17
    sqli-labs(less-11-16)
    sqli-labs (less-8-less-10)
    less-7
  • 原文地址:https://www.cnblogs.com/ShuComputerProgram/p/10829125.html
Copyright © 2020-2023  润新知