使用星型(*)Python转换的短路算法
一个名为使用星型(*)Python转换的短路算法,python,sorting,Python,Sorting,一个名为fungsiIO的函数,它没有输入参数,用于将用户的输入更改为整数,该整数用空格分隔以打印星号(*)字符。这些星星从最小的(顶部)到最大的(底部)排序 注:仅一次输入命令/输入功能 我的代码: def fungsiIO(): pass #???? 运行/调用函数: fungsiIO() # example input 7 4 5 3 1 2 投入和预期产出: 7 4 5 3 1 2 * ** *** **** ***** ******* 非常感谢所有帮助我的
fungsiIO
的函数,它没有输入参数,用于将用户的输入更改为整数,该整数用空格分隔以打印星号(*)字符。这些星星从最小的(顶部)到最大的(底部)排序
注:仅一次输入命令/输入功能
我的代码:
def fungsiIO():
pass
#????
运行/调用函数:
fungsiIO() # example input 7 4 5 3 1 2
投入和预期产出:
7 4 5 3 1 2
*
**
***
****
*****
*******
非常感谢所有帮助我的人您需要使用
sorted()
这将按升序对您的数字进行排序
你可以读更多
def sol(nums):
对于排序中的i(nums):
打印(“*”*i,结束=“”)
打印()
溶胶([7,4,5,3,1,2])
输出:
这是解决办法
def fungsiIO():
numbers = set(map(int, input().split()))
# if you enter 7 4 5 3 1 2 then
# numbers will be {1, 2, 3, 4, 5, 7}, sorted and all unique.
for num in numbers:
print("*"*num,end='')
print()
fungsiIO()
python 3或2?
我的代码
,代码在哪里?看不到任何东西!!在Python3中。。。。
def fungsiIO():
numbers = set(map(int, input().split()))
# if you enter 7 4 5 3 1 2 then
# numbers will be {1, 2, 3, 4, 5, 7}, sorted and all unique.
for num in numbers:
print("*"*num,end='')
print()
fungsiIO()