【问题标题】:python program related to strings字符串相关的python程序
【发布时间】:2017-10-11 05:25:37
【问题描述】:

要求用户输入 T 或 S 或 R。如果输入的字符串是 T 则打印公式 三角形的面积。如果输入的字符串是 S 则打印面积的公式 广场。如果是R,则打印矩形面积公式。

【问题讨论】:

  • 您实际上还没有问过问题。请阅读How to Ask
  • 那么,你希望我们做你的功课吗?
  • 这里没有代码编写服务。请添加您尝试过的代码,然后寻求帮助

标签: python string


【解决方案1】:
import os

while(True):
    print('T: formula of the area of the triangle \n S: formula of the area of the square \n R: formula of the area of the rectangle \n')
    x = raw_input('Enter your option: ')

    if str(x.upper()) == 'T':
       print "area = h*b/2 \n"
    elif str(x.upper()) == 'S':
       print "area = a*a \n"
    elif str(x.upper()) == 'R':
       print "area = w*l \n"
    else:
       print "Please enter a valied input \n"

给你

【讨论】:

    猜你喜欢
    • 2018-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    相关资源
    最近更新 更多