初级:
上课代码熟练操作
中级:
1. 从控制台输入圆的半径,计算周长和面积
import math
bj=12
print(2*math.pi*bj)#这是求圆的周长
print(math.pi*bj*bj)#这是求圆的面积
2. 一辆汽车以40km/h的速度行驶,行驶了45678.9km,求所用的时间
Time = 45678.9/40
print("时间:%s"% Time)
3. 华氏温度转摄氏温度【提示:将华氏温度转换为摄氏温度 F = 1.8C + 32】
οF = 50
℃ = (οF - 32) / 1.8
Print(c) #输入值为10
- 从控制台输入两个数,输出两个数相加,减法,求余数的结果
Aa = 10
Bb = 5
print(Aa+Bb)
print(Aa-Bb)
print(Aa%Bb)
游戏输出:
英雄联盟
键盘输入:
人物角色
初始装备
再购买3件装备(提示:要求键盘输入三次装备名称和价格)
最后计算买装备的总金额
最后输出:
xxx所购买的装备有哪些,共花费xxx钱
aa1 = input('英雄联盟装备1名称:')
jiage1 = input('价格:')
aa2 = input('英雄联盟装备2:')
jiage2 = input('价格:')
aa3 = input('英雄联盟装备3:')
jiage3 = input('价格:')
zongjia = int(jiage1)+int(jiage2)+int(jiage3)
mingchen=(aa1+aa2+aa3)
print("xxx所购买的装备有:%s"%mingchen,"共花费%s"%zongjia)
- 计算如下值:
a=10
b=8
计算 a+=b ,a-=b a*=b a/=b 的值
a+=b = 18 ,a-=b =2 a*=b = 80 a/=b=1.25
a//b 和 a**b 的值
a//b=1 a**b=100000000
- 尝试如下动作:
Print(‘*’ * 100) 的结果是什么
*********************************************************************** *****************************
l输出100个*
Print(‘hello’ * 5) 的结果是什么
hello hello hello hello hello 输出 5个hello
预习: 关系运算符 和 赋值运算符 位运算符