当前位置:网站首页>计算矩形面积
计算矩形面积
2022-06-29 02:12:00 【长街395】
描述
用户输入矩形的长和宽,计算其面积并输出。
a = eval(input()) #输入整数字符串,转换为整数;输入浮点数字符串,转换为浮点数
b = float(input()) #输入整数和浮点数,都转换为浮点数
c = int(input()) #只接受整数输入,输出为整数
#eval()和float()函数都可以把input() 函数接收到的数值型字符串转为数值类型
#例:float('3.14') 的结果是数值 3.14
#int()函数可以把整数字符串转为整数
#例:int('5') 的结果是数值 5
输入格式
第一行输入一个数字,代表矩形的长
第二行输入一个数字,代表矩形的宽
(输入使用input(),不要增加额外的提示信息)
输出格式
输出矩形的面积,不限定小数位数
示例 1
输入:
3.1415926
5.88
输出:
18.472564488
示例 2
输入:
5
8
输出:
40 解:
#用户输入长和宽,计算矩形的面积
width = eval(input()) # 输入宽
length = eval(input()) # 输入长
area = width * length # 计算面积
print(area) # 输出面积
边栏推荐
- 指南针手机股票开户哪个券商更安全更方便?
- 请问etf基金是否靠谱,安全吗
- How to become a senior digital IC Design Engineer (4-2) script: file read / write operation realized by Verilog HDL code
- 基于 FPGA 的 RISC CPU 设计(4)关于项目的 36 个问题及其答案
- 【Redis】Hash类型
- How to become a senior digital IC Design Engineer (6-5) digital IC Verification: coverage collection
- Interviewer: with the for loop, why do you need foreach??
- 瀑布型项目管理最常用的10个小工具,可以自由搭建使用
- Zhongyi technology resumed the review status of the gem IPO, and xuxiaofei no longer acted as a practicing lawyer
- How to manage device authorization
猜你喜欢
Scala Foundation (3): Operators and Process Control

SystemVerilog structure (I)

Introduction to super dongle scheme

Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin

如何成为一名高级数字 IC 设计工程师(4-3)脚本篇:C 语言实现的文件读写操作

Flex application: realize two rows and five columns of data, self-adaptive
![[redis] list type](/img/c7/adec2aaea50d69a0aed95bfe683b9e.png)
[redis] list type
![[understanding of opportunity -33]: seeing is not necessarily true. Most of the time,](/img/60/703a5bc3038d28bcf812415032f240.jpg)
[understanding of opportunity -33]: seeing is not necessarily true. Most of the time, "seeing is false"

Interviewer: with the for loop, why do you need foreach??

干货丨微服务架构是什么?有哪些优点和不足?
随机推荐
Interviewer: with the for loop, why do you need foreach??
Chrome browser close update Popup
QT basics tutorial: qstringlist
Why install an SSL certificate on a web site?
How to prevent virus
Smart world 2030
[network communication learning notes] socket IO setup and deployment
[learning notes] subsets and questions
大三下期末考試
110. simple chat room 13: chat room server
Blog publishing test 1
How to become a senior digital IC Design Engineer (6-7) digital IC Verification: debug skills
Tiflash compiler oriented automatic vectorization acceleration
Cross border information station
如何成为一名高级数字 IC 设计工程师(6-7)数字 IC 验证篇:DEBUG 技巧
Server antivirus
扁平结构转换为树结构
Large scale visual relationship understanding
Adding, deleting, checking and modifying stack - dynamic memory
[understanding of opportunity -33]: seeing is not necessarily true. Most of the time, "seeing is false"