码迷,mamicode.com
首页 > 编程语言 > 详细

python作业

时间:2017-09-06 20:46:04      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:oat   输出   一行代码   print   功能   word   计算   python   hello   

把自己写的练习代码贴出来。

我们是做练习,请大家一句代码一句代码自己敲出来,不熟悉就多敲几遍,不要复制粘贴,没有意义。

  1. 简单输入输出交互。

>>> print("hello word")
hello word
>>> input("hello word")
hello word

        2.用户输入两个数字,计算并输出两个数字之和:(尝试只用一行代码实现这个功能)

>>> n=input("input:")
input:1
>>> m=input("input:")
input:2
>>> int(n)+int(m)
3

>>> n+m
‘12‘

        3.输入半径,计算圆的面积。

>>>R=input(‘请输入半径:‘

>>>L=3.14

>>>print(’圆的面积为:%s‘%(float(r)**2*L))

请输入半径:2

圆的面积为:12.56

python作业

标签:oat   输出   一行代码   print   功能   word   计算   python   hello   

原文地址:http://www.cnblogs.com/Carrie-chong/p/7485226.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!