2021-06-16


字符转换/输入/计算

1. 从控制台输入圆的半径,计算周长和面积

circleR = input('圆的半径是:')
perimeter = 3.14*int(circleR)*2
area = 3.14*(int(circleR) ^ 2)
print('圆的周长是{},圆的面积是{}'.format(perimeter, area))

2. 一辆汽车以40km/h的速度行驶,行驶了45678.9km,求所用的时间

velocity = 40
distance = 45678.9
time = distance/velocity
print('时间是', time)

3. 华氏温度转摄氏温度【提示:将华氏温度转换为摄氏温度 F = 1.8C + 32】

F_Temp = input('华氏温度是:')
C_Temp = (int(F_Temp)-32)/1.8
print('摄氏温度是:', C_Temp)

**4. 从控制台输入两个数,输出两个数相加,减法,求余数的结果**
number_1 = input('请输入数字1:')
number_2 = input('请输入数字2:')
add = float(number_1)+float(number_2)
subtract = float(number_1) - float(number_2)
print('相加等于{},相减等于{}'.format(add, subtract))
remainder = float(number_1) % float(number_2)
print('余数是', remainder)

5.
**游戏输出:

''' 
英雄联盟
键盘输入:
人物角色
初始装备
再购买3件装备(提示:要求键盘输入三次装备名称和价格)
最后计算买装备的总金额
最后输出:
xxx所购买的装备有哪些,共花费xxx钱**
'''
print('英雄联盟')
role = input('人物角色:')
equip = input('初始装备:')
newEquip1 = input('购买装备1:')
price1 = input('装备1金额:')
newEquip2 = input('购买装备2:')
price2 = input('装备2金额:')
newEquip3 = input('购买装备3:')
price3 = input('装备3金额:')
total = float(price1)+float(price2)+float(price3)
print('{}所购买的装备是{},{}和{}, 共花{}元'.format(role, newEquip1, newEquip2, newEquip3, total))

6. 计算如下值:

# a=10
# b=8
# 计算 a+=b  ,a-=b  a*=b  a/=b 的值
a//b  和  a**b 的值**
a = 10
b = 8
a += b
print(a)
a -= b
print(a)
a *= b
print(a)
a /= b
print(a)
print(a//b)
print(a**b)

7. 尝试如下动作:
Print(‘*’ * 100) 的结果是什么
Print(‘hello’ * 5) 的结果是什么

hellohellohellohellohello

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值