编写一个程序来转换米和额外的厘米(不是两个单独的距离!)到英尺和英寸(再次,一个距离)。 Python 3 [英] Write a program to convert meters and additional centimeters (not two separate distances! ) Into feet and inches (again, one distance). Python 3

查看:131
本文介绍了编写一个程序来转换米和额外的厘米(不是两个单独的距离!)到英尺和英寸(再次,一个距离)。 Python 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助,它是我的等级的一部分,我已经做了很多次,但是当我总是把它弄错了。这是我的最后一次机会。









1.用户将为米和厘米输入两个整数。



2.程序将输出相同的英尺和英寸数。



3.使用这些转换因子:



。一米等于100厘米,

。一厘米等于0.393700787英寸和

。一英尺12英寸。





样品运行:



输入米数:342

输入厘米数:45

相当于1123英尺和6.28英寸。





1.首先,确定厘米的总数。

2.然后将其转换为总英寸。

3.将(英寸整数除法)总英寸除以12以确定总英尺数。

4.将总英寸上的模数(得到余数)乘以12以确定剩余的英寸数。英尺是一个整数。

5.要显示英寸,请将其四舍五入到小数点后两位。



我试过的是什么:



PLEASE HELP, ITS A PART OF MY GRADE, I'VE TRIED SO MANY TIMES, BUT WHEN I TURN IT IN ITS ALWAYS WRONG. THIS IS MY LAST CHANCE.




1. The user will enter two whole numbers for the meters and centimeters.

2. The program will then output the equivalent number of feet and inches.

3. Use these conversion factors:

. one meter equals 100 centimeters,
. one centimeter equals 0.393700787 inches and
. there are 12 inches in a foot.


Sample run:

Enter the number of meters: 342
Enter the number of centimeters: 45
That's equivalent to 1123 feet and 6.28 inches.


1. First, determine the total number of centimeters.
2. Then convert that to total inches.
3. Divide (integer division) total inches by 12 to determine the total number of feet.
4. Use modulus on total inches (get remainder) by 12 to determine the remaining number of inches. Feet will be an integer.
5. To display inches, round it to two decimal places.

What I have tried:

meter = int(input("Type meters: "))
centimeter = int(input("Type centimeter value: "))

meter2centimeter = 100
centimeter2inches = 0.393700787
foot2inches = 12

feet = meter * centimeter2inches * meter2centimeter/foot2inches
inches = centimeter * centimeter2inches

print(feet)
print(inches)

推荐答案

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是我们不会为你做这一切!



我会给你一些帮助,但没有代码 - 这是你的功课,不是我的!



首先阅读问题。

从那里,您必须从用户读取两个值,并将它们转换为英制测量值。

因此,您需要对这两个数字做的第一件事就是将它们转换为常用度量:将米转换为厘米(您有转换因子)并将其添加到厘米中以获得总计厘米。

然后将厘米转换成英寸(你也有这个因素)。

然后找出有多少英寸的英尺(提示:整数除法将除去小数部分)并存储它。使用脚数或'%'(模数)运算符找出剩余的英寸数。

打印它们。



这个并不困难 - 只需停止SHOUTING,停止恐慌,坐下来思考。
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

I'll give you a little help, but no code - this is your homework, not mine!

Start by reading the question.
From that, you have to read two values from the user, and convert them to imperial measurements.
So the first thing you need to do with the two numbers is convert them to a "common" measure: convert the meters to centimeters (you have that conversion factor) and add it to the centimeters to get a total in centimeters.
Then convert the centimeters into inches (you have that factor as well).
Then find out how many whole feet there are in the number of inches (hint: integer division will get rid of fractional parts) and store that. Either using the feet count or the '%' (modulus) operator find out the remaining number of inches.
Print them.

This is not difficult - just stop SHOUTING, stop panicking, and sit down and think.


在你的代码中,你错过了:

In your code, you missed:
Quote:

1。首先,确定厘米的总数。

1. First, determine the total number of centimeters.



这很重要因为米和厘米而不是英寸和英尺的精确倍数。



建议:拿一张纸和一支铅笔,用示例练习转换,直到掌握算法。仔细阅读要求,5个步骤就是你的算法。

一旦你掌握了细节,就写下你的代码。



我们不做你的家庭工作。

HomeWork不会测试你乞求别人做你的工作的技能,它会让你思考并帮助你的老师检查你对你所学课程的理解以及你应用它们时遇到的问题。

如果您失败,将帮助您的老师发现您的弱点并设置补救措施。


And this matters because meters and centimeters and not exact multiples of inches and foot.

Advice: Take a sheet of paper and a pencil, practice the conversion with examples until you master the algorithm. Read carefully the requirement, the 5 steps is your algorithm.
Once you master the details, write your code.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.


这篇关于编写一个程序来转换米和额外的厘米(不是两个单独的距离!)到英尺和英寸(再次,一个距离)。 Python 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆