python基础练习

 



1>>> print('hellow world:')
hellow world:
>>> input('piease input your name:')
piease input your name:du
'du'
>>> print(name)

>>> name=input(:)
SyntaxError: invalid syntax
>>> name=input(':')
:du
>>> name='duym'
>>> print(name)
duym
>>> name=input('what is your name?\n')
what is your name?
dd
>>> print('hi,%s'%name)
hi,dd
>>>

2 num1=input('请输入第一个数字:')

num2=input('请输入第二个数字:')

sun=float(num1)+float(num2)

print('数字{0}和{1}相加结果为:{2}'.format(num1,num2,sum))

          

        

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

     P=3.14

     print('圆的面积为:%.2f' %((float(input('请输入圆的半径:'))**2)*P))

            请输入圆的半径:2

             圆的面积为:12.56

 

posted on 2017-09-06 16:01  133陈贝  阅读(214)  评论(0编辑  收藏  举报