python - How can I spontaneously print a loop in function python
问题描述
so i am doing a computational physics homework, i need to make a calculator to calculate a range of number from 1 to 10 which is time (t) to my function. My code looks like this
import numpy as np
def vonx(v,theta):
theta_to_radian = np.deg2rad(theta)
vx = v*np.cos(theta_to_radian)*time
return vx
so how do i spontaniously calculate this equation including time and have multiple answer?
also, can I use input to input the value of v and theta?
解决方案
假设您要动态打印从 0 到 10 的 vx 值:
import numpy as np
v = int(input())
theta = int(input())
def vonx(v,theta, time):
theta_to_radian = np.deg2rad(theta)
vx = v*np.cos(theta_to_radian)*time
return vx
for time in range(11):
print(vonx(v,theta,time))
推荐阅读
- android - 我一直在尝试将数据从移动应用程序(Android/IOS)推送到 kafka 代理?
- uwp - 在 UWP 中擦除部分描边
- android - Flutter Widgets 对齐没有响应
- javascript - 存储实时 htmlCollection 与迭代项目 ID 数组(和树遍历)的成本
- java - 如何在嵌入式 spring ldap 服务器中启用附加模式?
- ios - Xcode Instruments,网络连接:发送的总字节数少于实际
- sql-server - 使用 patindex 连接两个表列的性能调整
- c# - 无法保存“AssemblyInfo.cs”,因为它未在编辑器中打开
- c# - c#如何验证用户的类型?
- android - 从 sqlite android 实现更好的搜索