question1:运算优先级问题
1.乘除优先加减
2.位运算 == 算数运算 > 比较运算 > 赋值运算 > 逻辑运算
a,b,x,y = 10, 20, 30, 40 d = (5 + 10 * x)/5 -13 * (y - 1) * (a + b)/x + 9*(5 / x + (12 + x)/y) print(d)
question2:input()的使用
从控制台输入用户的月薪,进行运算计算出年薪。打印输出用户的年薪
notes:input()获得的为string,要转为int
month_salary = input() month_salary = int(month_salary) year_salary = 12 * month_salary print(year_salary)
questions3:字符串的倒序输出
str = 'to be or not to be' len_str = len(str) str_reverse = str[::-1] print(str_reverse)
questions4:输出指定位置字符
notes:第一个位置为0
str = 'sxtsxtsxtsxtsxt' ''' place = 0 3 6 9 12 ''' str_s = str[0:len(str):3] print(str_s)
question5:is 的含义和字符串驻留机制
a = "abd_33" b = "adb_33" c = "dd#" d = "dd#" e = a is b f = c is d print(e,f)
a is b ture
c is d false
a is b,a b满足python的字符串驻留机制,所以ture
c is d,c d不满足,false
驻留机制出发条件:字符串仅包含下划线(_)、字母和数字
question6:format使用
c = "名字是{name},年龄是{age}"
print(c)
print(c.format(age=19,name='高淇'))
'''
>>>
名字是{name},年龄是{age}
名字是高淇,年龄是19
'''



