摩托车论坛

搜索
查看: 5188|回复: 1
打印 上一主题 下一主题

[代码]算车子真实排量单缸版使用在线编译器 lua/python

[复制链接]

状态   [当前离线]

跳转到指定楼层
楼主
发表于 北京市 2020-5-13 10:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
0.找个在线编译器本例为 https://c.runoob.com/compile/66
1.复制下述代码:
--MIT licence, lua ver 5.3.5
function displacement(b, s) return (b/2)^2 * math.pi * s end
function cut(o, d) return o-o%10^-d end

bore, stroke = 82, 53.6 --长度 mm
print("缸径:", bore, "mm, 压缩行程:", stroke, "mm; 引擎排量:", cut(displacement(bore, stroke)/1000, 2), "cc")

2.把变量 bore, stroke = 82, 53.6 分别改称你车的机子参数, 贴到线编译器里
3.点击运行之后看结果

NC300 实际排量 283.06 cc 差这么多好意思叫三百呢

python 在线编译器 https://c.runoob.com/compile/9
与代码:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# MIT licence
import math

def displacement(b, s) : return (b/2)**2 * math.pi * s

bore, stroke = 82, 53.6 # mm
print(
  "bore:", bore, "mm, stroke:", stroke, "mm; engine displacement:",
   round(displacement(bore, stroke)/1000, 2), "cc"
)



想把树莓派装车号码牌后面但一直懒癌末期, 现 qpython 装手机上瞎对付呢
的确对飞了多高多远, 爬了多大的坡有兴趣研究但时间少啊看来得等退休再搞啦




回复

使用道具 举报

状态   [当前离线]

沙发
发表于 湖北省 2020-5-13 12:17 | 只看该作者
编辑器与编译器的区别可不是一点点……
回复

使用道具 举报

发新帖

QQ|小黑屋|手机版|Archiver|中国摩托迷网

GMT, 2025-7-11 22:18

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表