python失败的尝试们

这里收集我那些失败的尝试😫

打印正三角形
row = int(input('Please enter the row number: '))
for i in range(row):
    for j in range(row):
        if j<row-i-1:
            print(' ',end='') 
        else:
            print(2*'*',end='')
    print() 
Please enter the row number: 5
    **
   ****
  ******
 ********
**********

·

===============================================

一个同样失败的骰子游戏…
"""
玩家摇两个骰子,如果两个骰子数字相等,则玩家赢,若不相等,则继续
如果两个骰子数字相等,则庄家赢,若不相等,则继续
"""

from random import randint
money = 5
while money>0:
    print('left: ')
    needs_go_on = False
    while True:
        debt = 1
        if debt <= money:
            break
    first1= randint(1,6)
    first2= randint(1,6)
    print(f'the result is {first1} and {first2}')
    if first1==first2:
        print('玩家胜!')
        money += debt
    else:
        print('庄家胜!')
        money -= debt
        needs_go_on = True

    while needs_go_on:
        then1= randint(1,6)
        then2= randint(1,6)
        print(f'the result is {then1} and {then2}')
        if then1==then2:
            print('庄家胜!')
            money -= debt
            needs_go_on = False
print(' game over')


# edit
from random import randint
money = 5
while money>0:
    print('left: ')
    needs_go_on = False
    while True:
        debt = 1
        if debt <= money:
            break
    first1= randint(1,6)
    first2= randint(1,6)
    print(f'the result is {first1} and {first2}')
    if first1==first2:
        print('玩家胜!')
        money += debt
    else:
        print('庄家胜!')
        money -= debt
        needs_go_on = True

    while needs_go_on:
        then1= randint(1,6)
        then2= randint(1,6)
        print(f'the result is {then1} and {then2}')
        if then1==then2:
            print('庄家胜!')
            money -= debt
            needs_go_on = False
print(' game over')

·
·

==============================================

light
import os
import time

def main():
    content = '王一博冲鸭!'
    while True:
        os.system('cls')
        print(content)
        time.sleep(0.2)
        content = content[1:]+content[0]
main()

不要随便尝试,停不下来哎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值