python - 如何在网站上执行 Python 函数?
问题描述
我是鲨鱼坦克电视剧的忠实粉丝,我真的找不到任何与之密切相关的模拟器或游戏。所以我尝试制作一个简单的python函数来模拟鲨鱼坦克比赛的基础知识。
@author: JIBIN
"""
def Shark_Tank():
import numpy as np
import sys
initial=1000000 #ignore this value
a=np.random.randint(5,50) #ignore this value
b=np.random.random(1) #ignore this value
capital=int(np.random.random(1)*100) #capital asked by contestant
equity=int(np.random.choice(51)) #equity asked by contestant
valuation=capital/(equity/100) #business valuation calculation
print("We are seeking an investment of ",capital, " thousand with an equity stake of ",equity,"% of our company")
print("Business Valuation is ",valuation," thousand")
print("Revenue: USD",int(np.random.random(1)*60), "thousand")
print("Counter Offer? (1.Yes/2.No/3. Not Interested)")
d=int(input("Enter your choice(1/2/3):"))
if d==1:
counter_capital=int(input("I will give you capital of USD "))
counter_equity=int(input("for an equity percentage of "))
print("That would be for a valuation of USD ", counter_capital/(counter_equity/100))
elif d==2:
print("I will give you what you ask for. I like your offer")
sys.exit(0)
else:
print("Not interested in investing, but goood luck)")
sys.exit(0)
z=np.random.randint(2)
if z==0:
print("The counter offer looks good. We have a deal!")
initial=initial-counter_capital
else:
print("How about we give ", np.random.randint(equity-1,counter_equity),"% of our company for USD ",np.random.randint(counter_capital,capital)," thousand?")
j=int(input("Will you take the counter offer of the entrepreneur? (1.Yes/2.No)"))
if j==1:
print("I will take that offer! Thats a deal!")
else:
print("Sorry mate, I cannot give you that with this valuation")
Shark_Tank()
我的想法是制作一个好的用户界面,比如一个可以运行这个 python 函数的网页。在Spyder中可以做到这一点吗?或者,如果可能的话,我如何将其链接到 HTML 网页?
PS:上面的代码是鲨鱼坦克模拟的一个非常简化的版本,专为扮演鲨鱼之一的单人玩家而设计。我只是在空闲时间编写了这个代码,并希望看到它具有更好的用户交互性。
解决方案
推荐阅读
- python - 使用 Multidict 将 Numpy 数组转换为字典
- android - 如何在 Flutter 中对现有数组进行排序和制作?
- android - 将布局文件共享为可打开的链接
- android - app:compileFlutterBuildRelease 构建应用程序颤动时出错
- c# - .NET - c# - 需要跨分区查询,但禁用文档数据访问问题
- go - splitsh / lite:在 Windows 10 上构建时出错
- django - Django 搜索返回“找不到页面 (404) 错误
- javascript - react-redux 搜索过滤器的问题
- r - Data.table 单线程警告
- c# - VS Code / OmniSharp failing to load project; Can't find a package that is present