如何添加最短日期和最长日期的日期

发布于 2025-01-17 14:03:23 字数 303 浏览 2 评论 0原文

一个问题指出,我正在制作一个程序,其中用户添加了他在股票市场投资的天数。此后,他增加了价格,并以最高和最低的价格增加了最高和最低的价格。

N = int(input("Namuber of days: "))
x_list = []

for i in range(N):
    x = float(input("Enter a set of stock prices on day{}: ".format(i+1)))
    x_list.append(x)

print(max(x_list))
print(min(x_list))

A question states that I am making a program where the user adds the number of days he invested in the stock market. After that, he adds the prices and shows the highest and lowest price with the addition of the day at the highest and lowest price.

N = int(input("Namuber of days: "))
x_list = []

for i in range(N):
    x = float(input("Enter a set of stock prices on day{}: ".format(i+1)))
    x_list.append(x)

print(max(x_list))
print(min(x_list))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笏见 2025-01-24 14:03:23

您需要打印index maxmin价格。

print(x_list.index(max(x_list)))
print(x_list.index(min(x_list)))

You need to print the index of the max and min prices instead.

print(x_list.index(max(x_list)))
print(x_list.index(min(x_list)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文