星号菱形——python

a=input("英文符号:")
n=input("输入奇数:")
for i in range(1,num+1,2):
    print((i*s).center(num))
for i in range (num-2,0-2):
    print((i*s).center(num))

姐妹们我不知道我做的对不对欸

a=int(input())
n=input()
for i in range(1, a+1, 2):
    print((s * i).center(a))
for i in reversed(range(1, a-1, 2)):
    print((s * i).center(a))

还有一个


rows = int(input('请输入菱形边长:\n'))
row = 1
while row <= rows:
    col = 1    
    while col <= (rows-row):  
        print(' ', end='')  
        col += 1
    print(row * '* ') 
    row += 1
 
bottom = rows-1
while bottom > 0:
    col = 1   
    while bottom+col <= rows:
        print(' ', end='') 
        col += 1
    print(bottom * '* ') 
    bottom -= 1

再加一个

s = '*'
for i in range(1, 8, 2):
    print((s * i).center(7))
for i in reversed(range(1, 6, 2)):
    print((s * i).center(7))

这个没有设置input 可以自己改一下

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值