与孩子一起学编程05章

动手试一试:

1.2.两个变量的编程:

  

# -*- coding: UTF-8 -*-
#输入,你姓什么?(记住要有字符串,这是很好的)
first = raw_input('enter you first name:')
last =raw_input ('enter you last name:')
print 'Hello,', first,last, 'How are you today?'

3.

length =float(raw_input('输入房间的长:'))
width =float(raw_input('输入房间的宽:'))
area =length * width
print '面积是:',area

4.


# -*- coding: UTF-8 -*-
length =float(raw_input('输入房间的长:'))
width =float(raw_input('输入房间的宽:'))
cost_per_yard = float(raw_input('输入每码多少钱:'))
area =length * width
area_yards = area / 9.0
total_cost = area_yards * cost_per_yard
print '面积是:',area,'平方米'
print'总共有多少码:',area_yards,''
print('总价:'),total_cost,''

5.

# -*- coding: UTF-8 -*-
#记住:raw_input("输入五分币")
m5 = float(raw_input('五分币:'))
#:float!!!!!!
m2 = float(raw_input('2分币:'))
m1 = float(raw_input('1分币:'))
zj = (m5 * 5) + (m2 * 2) + (m1)
#','在外面
print('总价钱是:'), zj

展开阅读全文

没有更多推荐了,返回首页