欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Homework Day2

程序员文章站 2022-06-10 16:05:44
...

Homework Day2

def main():
    import math
    a,b,c = map(float,input('请输入三个数字a,b,c:').split(','))
    D = (b*b)-(4*a*c)
    if D>0:
        D1 = (-b+math.sqrt(b*b-4*a*c))/2*a
        D2 = (-b-math.sqrt(b*b-4*a*c))/2*a
        print('两个跟分别是 %f 和 %f'%(D1,D2))
    elif D == 0:
        D1 = (-b+math.sqrt(b*b-4*a*c))/2*a
        print('两个相等根是%f'%D1)
    else:
        print('没有实数跟')
def Start():
    main()
Start()

Homework Day2

def main():
    import random
    a1 = random.randint(0,100)
    a2 = random.randint(0,100)
    print(a1,a2)
    a3 = int(input("请输入您猜的数字:"))
    if a3 == (a1+a2):
        print('真')
    else:
        print('假')
def Start():
    main()
Start()

Homework Day2

def week():
    today = int(input("输入今天星期几:"))
    day = int(input("未来的第几天:"))
    weekend = ['周日','周一','周二','周三','周四','周五','周六']
    weilai = today + day
    new = 0
    new = weilai%7
    print("今天是%s 未来是%s" %(weekend[today],weekend[new]))
def Start():
    week()
Start()

Homework Day2

n1 = int(input('请输入第一个整数:'))
n2 = int(input('请输入第二个整数:'))
n3 = int(input('请输入第三个整数:'))
x = [n1,n2,n3]
x.sort()
print(x)

Homework Day2

def main():
    weight1 =float(input("第一个重量:"))
    price1 = float(input('第一个价钱:'))
    weight2 =float(input("第二个重量:"))
    price2 = float(input('第二个价钱:'))
    bijiao1 = weight1/price1
    bijiao2 = weight2/price2
    if bijiao1 > bijiao2:
        print('第一个更好')
    elif bijiao1 == bijiao2:
        print('两种一个样子')
    else:
        print('第二种更好')
def Start():
    main()
Start()

Homework Day2

def main():
    year = int(input("输入年:"))
    month = int(input("输入月:"))
    if(year%4==0 and year%100 !=0) or (year%400==0):
        day2 = int('29')
    else:
        day2 = int('28')
    if month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12:
        day = int('31')
    elif month == 4 or month == 6 or month == 9 or month == 11:
        day = int('30')
    else:
        day = day2
    print('%d年%d月有%d天'%(year,month,day))
def Start():
    main()
Start()

Homework Day2

def main():
    import random
    comp = random.randint(1,2)
    user = int(input("1为正面,2为反面,请输入????:"))
    if comp ==user:
        print("yes获得十万金币")
    else:
        print("哥哥你真好,你就是个大傻吊")
def Start():
    main()
Start()

Homework Day2

def main():
    import random
    user = int(input("石头剪刀布出一个吧剪刀(0), 石头(1), 布(2):"))
    comp = random.randint(0,2)
    print(comp)
    if (user==1 and comp==0) or (user==0 and comp==2) or (user==2 and comp ==1):
        print("YOU WIN GREAT BOODY")
    elif user==comp:
        print('Sorry Sir But You Do not Lost Any Thing')
    else:
        print("You Are A Losser Please Shut UP")
def Start():
    main()
Start()

Homework Day2

def main():
    year = int(input('输入哪一年:'))
    m = int(input('输入月份1-12:'))
    d = int(input('输入月份第几天1-31:'))
    a = ['周六','周日','周一','周二','周三','周四','周五']
    if m == 1:
        m = 13
        year = year - 1
    if m ==2:
        m = 14
        year = year - 1
    h = int(d+((26*(m+1))//10)+(year%100)+((year%100)/4)+((year//100)/4)+5*year//100)%7
    day = a[h]
    print('那一天是一周中的:%s' %day)
def Start():
    main()
Start()

Homework Day2

def chou():
    import numpy as np
    daxiao=np.random.choice(['Ace','2','3','4','5','6','7','8','9','10','Jack','Queen','King'])
    huase=np.random.choice(['梅花','红桃','方块','黑桃'])
    print('你选择的牌是',huase,daxiao)
def Start():
    a = input("是否决定抽牌y/n:")
    if a == 'y':
        chou()
    else:
        pass
Start()

Homework Day2

def main():
    a = int(input('请输入一个正整数: '))
    b = a
    a2 = 0
    while b > 0:
        a2 *= 10
        a2 += b % 10
        b //= 10
    if a == a2:
        print('%d是回文数' % a)
    else:
        print('%d不是回文数' % a)
def start():
    main()
start()

Homework Day2

def main():
    a = float(input("请输入第一条边长"))
    b = float(input("请输入第二条边长"))
    c = float(input("请输入第三条边长"))
    if a+b>c and a+c>b and b+c>a:
        L = a+b+c
        print("其周长为",L)
    else:
        print("不是三角形三条边") 
def Start():
    main()
Start()

作业就这样的算是写完了加油最后附赠一套情侣头像
Homework Day2
Homework Day2