Python Class 1

a=float(input("输入一个数:"))
b=float(input("再输入一个数:"))
c=a+b 
print(f"{a}+{b}的值是{c}")
import datetime
now=datetime.datetime.now()
print("你好,现在是",now.strftime("%H:%M:%S"))    
#string format time %H %M %S是格式化符号,类似还有%Y %m %d
import random
print("我这里有一个1到100之间的数字,请你来猜猜看!")
number=random.randint(1,100)
while True:
    a=int(input("你猜的数字是:"))
    if a<number:
        print("太小啦!")
    elif a>number:
        print("太大啦!")
    else:
        print(f"恭喜你!猜对了!这个数是{number}")
        break

    
name=input("hello,我是python,你叫什么名字:")
print(f"你好呀,{name}")
mood=input("你今天心情怎么样呀?(输入happy/sad/others)")
if mood=="happy":
    print("真好!祝你一天开心!")
elif mood=="sad":
    print("没关系,一切都会变好的")
else:
    print("希望你保持好心情~")
import random
a=random.randint(1,10)
print(f"你的幸运数字是:{a}")

print("输入两个整数a,b 其中a小于等于b")
a=int(input())    #以enter作为分隔
b=int(input())
c=random.randint(a,b)
print(f"你的幸运数字是:{c}")
import random

def gen_music():
    songs=[
        "特别的人",
        "爱我还是他",
        "稻香",
        "Hotel California",
    ]
    song=random.choice(songs)
    print(f"听听 {song} 吧")

def gen_game():
    games=[
        "第五人格",
        "原神",
        "和平精英",
        "蛋仔派对"
    ]
    game=random.choice(games)
    print(f"试试 {game} 吧")

print("觉得有些无聊?听音乐还是玩游戏?")
while True:
    choice=int(input("输入1选择音乐,2选择游戏:"))
    if choice==1 :
        gen_music()
    elif choice==2 :
        gen_game()
    else:
        print("输入错误,重来一次吧")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值